1 /* 2 * Copyright (C) 2015 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 android.support.test.filters.LargeTest; 20 21 import com.android.documentsui.files.FilesActivity; 22 23 @LargeTest 24 public class DirectoryMessagesUiTest extends ActivityTest<FilesActivity> { 25 26 public DirectoryMessagesUiTest() { 27 super(FilesActivity.class); 28 } 29 30 @Override 31 public void setUp() throws Exception { 32 super.setUp(); 33 bots.roots.openRoot("Demo Root"); 34 bots.main.switchToListMode(); 35 } 36 37 public void testAuthenticationMessage_visible() throws Exception { 38 // If feature is disabled, this test is a no-op. 39 if (!features.isRemoteActionsEnabled()) { 40 return; 41 } 42 bots.directory.openDocument(DemoProvider.DIR_AUTH); 43 bots.directory.assertHasMessage( 44 "To view this directory, sign in to DocumentsUI Tests"); 45 bots.directory.assertHasMessageButtonText("SIGN IN"); 46 } 47 48 public void testInfoMessage_visible() throws Exception { 49 bots.directory.openDocument(DemoProvider.DIR_INFO); 50 bots.directory.assertHasMessage(DemoProvider.MSG_INFO); 51 bots.directory.assertHasMessageButtonText("DISMISS"); 52 } 53 54 public void testInfoMessage_dismissable() throws Exception { 55 bots.directory.openDocument(DemoProvider.DIR_INFO); 56 bots.directory.assertHasMessage(true); 57 bots.directory.clickMessageButton(); 58 bots.directory.assertHasMessage(false); 59 } 60 61 public void testErrorMessage_visible() throws Exception { 62 bots.directory.openDocument(DemoProvider.DIR_ERROR); 63 bots.directory.assertHasMessage(DemoProvider.MSG_ERROR); 64 bots.directory.assertHasMessageButtonText("DISMISS"); 65 } 66 67 public void testErrorMessage_dismissable() throws Exception { 68 bots.directory.openDocument(DemoProvider.DIR_ERROR); 69 bots.directory.assertHasMessage(true); 70 bots.directory.clickMessageButton(); 71 bots.directory.assertHasMessage(false); 72 } 73 74 public void testErrorMessage_supercedesInfoMessage() throws Exception { 75 // When both error and info are returned in Directory, only show the error. 76 bots.directory.openDocument(DemoProvider.DIR_ERROR_AND_INFO); 77 bots.directory.assertHasMessage(DemoProvider.MSG_ERROR_AND_INFO); 78 } 79 } 80