1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.documentsui;
17 
18 import android.content.Intent;
19 import android.net.Uri;
20 import android.provider.DocumentsContract;
21 
22 import androidx.test.filters.LargeTest;
23 
24 import com.android.documentsui.inspector.InspectorActivity;
25 
26 @LargeTest
27 public class InspectorUiTest extends ActivityTest<InspectorActivity> {
28 
29     private static final String TEST_DOC_NAME = "test.txt";
30 
InspectorUiTest()31     public InspectorUiTest() {
32         super(InspectorActivity.class);
33     }
34 
35     @Override
setUp()36     public void setUp() throws Exception {
37         super.setUp();
38     }
39 
40     @Override
launchActivity()41     public void launchActivity() {
42         if (!features.isInspectorEnabled()) {
43             return;
44         }
45         Uri uri = DocumentsContract.buildDocumentUri(InspectorProvider.AUTHORITY, TEST_DOC_NAME);
46         final Intent intent = InspectorActivity.createIntent(context, uri, userId);
47         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
48         setActivityIntent(intent);
49         getActivity();
50     }
51 
testDisplayFileName()52     public void testDisplayFileName() throws Exception {
53         if (!features.isInspectorEnabled()) {
54             return;
55         }
56         bots.inspector.assertTitle("test.txt");
57     }
58 
testFolderDetails()59     public void testFolderDetails() throws Exception {
60         if (!features.isInspectorEnabled()) {
61             return;
62         }
63         bots.inspector.assertRowEquals(
64                 getActivity().getString(R.string.sort_dimension_file_type),
65                 "Folder",
66                 getActivity());
67         bots.inspector.assertRowEquals(
68                 getActivity().getString(R.string.directory_items),
69                 InspectorProvider.NUMBER_OF_ITEMS,
70                 getActivity());
71     }
72 }
73