• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 
17 package com.android.documentsui;
18 
19 import static com.android.documentsui.StubProvider.ROOT_0_ID;
20 import static com.android.documentsui.StubProvider.ROOT_1_ID;
21 
22 import android.os.RemoteException;
23 import android.support.test.filters.LargeTest;
24 import android.support.v7.recyclerview.R;
25 
26 import com.android.documentsui.base.RootInfo;
27 import com.android.documentsui.base.Shared;
28 import com.android.documentsui.files.FilesActivity;
29 
30 @LargeTest
31 public class FilesActivityDefaultsUiTest extends ActivityTest<FilesActivity> {
32 
FilesActivityDefaultsUiTest()33     public FilesActivityDefaultsUiTest() {
34         super(FilesActivity.class);
35     }
36 
37     @Override
initTestFiles()38     protected void initTestFiles() throws RemoteException {
39         // Overriding to init with no items in test roots
40     }
41 
42     @Override
getInitialRoot()43     protected RootInfo getInitialRoot() {
44         return null;  // test the default, unaffected state of the app.
45     }
46 
testDefaultDirectory()47     public void testDefaultDirectory() throws Exception {
48         device.waitForIdle();
49 
50         // Separate logic for "Documents" root, which presence depends on the config setting
51         if (docsRootEnabled()) {
52             bots.main.assertWindowTitle("Documents");
53         } else {
54             bots.main.assertWindowTitle("Downloads");
55         }
56     }
57 
testNavigate_FromEmptyDirectory()58     public void testNavigate_FromEmptyDirectory() throws Exception {
59         device.waitForIdle();
60 
61         bots.roots.openRoot(rootDir0.title);
62 
63         String msg = String.valueOf(context.getString(R.string.empty));
64         bots.directory.assertPlaceholderMessageText(msg);
65 
66         // Check to make sure back button is properly handled by non-Doc type DocHolders
67         device.pressBack();
68     }
69 
testDefaultRoots()70     public void testDefaultRoots() throws Exception {
71         device.waitForIdle();
72 
73         // Should also have Drive, but that requires pre-configuration of devices
74         // We omit for now.
75         bots.roots.assertRootsPresent(
76                 "Images",
77                 "Videos",
78                 "Audio",
79                 "Downloads",
80                 ROOT_0_ID,
81                 ROOT_1_ID);
82 
83         // Separate logic for "Documents" root, which presence depends on the config setting
84         if (docsRootEnabled()) {
85             bots.roots.assertRootsPresent("Documents");
86         } else {
87             bots.roots.assertRootsAbsent("Documents");
88         }
89     }
90 
docsRootEnabled()91     private boolean docsRootEnabled() {
92         return Shared.shouldShowDocumentsRoot(context);
93     }
94 }
95