Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.appmenu; | |
| 6 | |
| 7 import android.support.test.filters.SmallTest; | |
| 8 | |
| 9 import org.chromium.base.ThreadUtils; | |
| 10 import org.chromium.base.test.util.UrlUtils; | |
| 11 import org.chromium.chrome.test.BottomSheetTestCaseBase; | |
| 12 import org.chromium.content.browser.test.util.Criteria; | |
| 13 import org.chromium.content.browser.test.util.CriteriaHelper; | |
| 14 | |
| 15 /** | |
| 16 * Tests for the app menu when Chrome Home is enabled. | |
| 17 */ | |
| 18 public class ChromeHomeAppMenuTest extends BottomSheetTestCaseBase { | |
| 19 private static final String TEST_URL = UrlUtils.encodeHtmlDataUri("<html>poi t.</html>"); | |
| 20 | |
| 21 private AppMenu mAppMenu; | |
| 22 private AppMenuHandler mAppMenuHandler; | |
| 23 | |
| 24 @Override | |
| 25 protected void setUp() throws Exception { | |
| 26 super.setUp(); | |
| 27 | |
| 28 mAppMenuHandler = getActivity().getAppMenuHandler(); | |
| 29 showAppMenuAndAssertMenuShown(); | |
| 30 mAppMenu = getActivity().getAppMenuHandler().getAppMenu(); | |
| 31 getInstrumentation().waitForIdleSync(); | |
|
Ted C
2017/04/18 22:58:46
why do we need this?
Actually...why do we need sh
Theresa
2017/04/18 23:30:59
Done.
| |
| 32 } | |
| 33 | |
| 34 @SmallTest | |
| 35 public void testPageMenu() throws IllegalArgumentException, InterruptedExcep tion { | |
| 36 loadUrl(TEST_URL); | |
| 37 | |
| 38 AppMenuIconRowFooter iconRow = (AppMenuIconRowFooter) mAppMenu.getPrompt View(); | |
| 39 | |
| 40 assertFalse(iconRow.getForwardButtonForTests().isEnabled()); | |
| 41 assertTrue(iconRow.getBookmarkButtonForTests().isEnabled()); | |
| 42 // Only HTTP/S pages can be downloaded. | |
| 43 assertFalse(iconRow.getDownloadButtonForTests().isEnabled()); | |
| 44 assertTrue(iconRow.getPageInfoButtonForTests().isEnabled()); | |
| 45 assertTrue(iconRow.getReloadButtonForTests().isEnabled()); | |
| 46 | |
| 47 // Navigate backward, open the menu and assert forward button is enabled . | |
| 48 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | |
| 49 @Override | |
| 50 public void run() { | |
| 51 mAppMenuHandler.hideAppMenu(); | |
| 52 getActivity().getActivityTab().goBack(); | |
| 53 } | |
| 54 }); | |
| 55 | |
| 56 showAppMenuAndAssertMenuShown(); | |
| 57 iconRow = (AppMenuIconRowFooter) mAppMenu.getPromptView(); | |
| 58 assertTrue(iconRow.getForwardButtonForTests().isEnabled()); | |
| 59 } | |
| 60 | |
| 61 @SmallTest | |
| 62 public void testTabSwitcherMenu() throws IllegalArgumentException { | |
| 63 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | |
| 64 @Override | |
| 65 public void run() { | |
| 66 getActivity().getLayoutManager().showOverview(false); | |
| 67 } | |
| 68 }); | |
| 69 showAppMenuAndAssertMenuShown(); | |
| 70 | |
| 71 assertNull(mAppMenu.getPromptView()); | |
| 72 } | |
| 73 | |
| 74 private void showAppMenuAndAssertMenuShown() { | |
| 75 ThreadUtils.runOnUiThread(new Runnable() { | |
| 76 @Override | |
| 77 public void run() { | |
| 78 mAppMenuHandler.showAppMenu(null, false); | |
| 79 } | |
| 80 }); | |
| 81 CriteriaHelper.pollInstrumentationThread(new Criteria("AppMenu did not s how") { | |
|
Ted C
2017/04/18 22:58:46
why the instrumentation thread?
Theresa
2017/04/18 23:30:59
Changed it to poll the UI thread.
| |
| 82 @Override | |
| 83 public boolean isSatisfied() { | |
| 84 return mAppMenuHandler.isAppMenuShowing(); | |
| 85 } | |
| 86 }); | |
| 87 } | |
| 88 } | |
| OLD | NEW |