Commit c901c92a authored by Theresa Wellington's avatar Theresa Wellington Committed by Commit Bot

Add two simple tests for Android bottom toolbar

Add a new BottomToolbarTest class with two simple tests that check
bottom toolbar visibilty and tab switcher button click handling.

Also updates chrome/android/java/.../toolbar/OWNERS file to include
twellington@ and chrome/android/javatests/.../toolbar/OWNERS file to
point to non-test OWNERS file.

BUG=1008212

Change-Id: I46839e3b614a68af5c75bf876f3c47565db63e84
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1825787Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Theresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700260}
parent 65216b2c
......@@ -492,6 +492,7 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/toolbar/ToolbarProgressBarIntegrationTest.java",
"javatests/src/org/chromium/chrome/browser/toolbar/ToolbarProgressBarTest.java",
"javatests/src/org/chromium/chrome/browser/toolbar/ToolbarTest.java",
"javatests/src/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarTest.java",
"javatests/src/org/chromium/chrome/browser/toolbar/top/BrandColorTest.java",
"javatests/src/org/chromium/chrome/browser/toolbar/top/TabSwitcherActionMenuTest.java",
"javatests/src/org/chromium/chrome/browser/toolbar/top/TabSwitcherActionMenuRenderTest.java",
......
mdjones@chromium.org
tedchoc@chromium.org
yusufo@chromium.org
twellington@chromium.org
# COMPONENT: UI>Browser>Mobile
# COMPONENT: UI>Browser>Toolbar
# OS: Android
......@@ -356,6 +356,13 @@ public class FeatureUtilities {
&& !isTabGroupsAndroidEnabled();
}
/**
* Set whether the bottom toolbar is enabled for tests. Reset to null at the end of tests.
*/
public static void setIsBottomToolbarEnabledForTests(Boolean enabled) {
sIsBottomToolbarEnabled = enabled;
}
/**
* @return Whether or not the adaptive toolbar is enabled.
*/
......
tedchoc@chromium.org
yusufo@chromium.org
file://chrome/android/java/src/org/chromium/chrome/browser/toolbar/OWNERS
\ No newline at end of file
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.toolbar.bottom;
import android.support.test.filters.MediumTest;
import android.view.View;
import android.view.ViewGroup;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.OverviewModeBehaviorWatcher;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import java.util.concurrent.ExecutionException;
/**
* Integration tests for the bottom toolbar.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class BottomToolbarTest {
@Rule
public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule<>(ChromeActivity.class);
@Before
public void setUp() throws InterruptedException {
FeatureUtilities.setIsBottomToolbarEnabledForTests(true);
mActivityTestRule.startMainActivityOnBlankPage();
}
@After
public void tearDown() {
FeatureUtilities.setIsBottomToolbarEnabledForTests(null);
}
@Test
@MediumTest
public void testBottomToolbarVisibility() {
Assert.assertNotNull("BottomToolbarCoordinator should be constructed.",
mActivityTestRule.getActivity().getToolbarManager().getBottomToolbarCoordinator());
View bottomToolbar = mActivityTestRule.getActivity().findViewById(R.id.bottom_toolbar);
Assert.assertEquals("Bottom toolbar view should be visible.", View.VISIBLE,
bottomToolbar.getVisibility());
}
@Test
@MediumTest
public void testBottomToolbarTabSwitcherButton() throws ExecutionException {
Assert.assertFalse("Tab switcher should not be visible.",
mActivityTestRule.getActivity().getOverviewModeBehavior().overviewVisible());
ViewGroup bottomToolbar = mActivityTestRule.getActivity().findViewById(R.id.bottom_toolbar);
View tabSwitcherButton = bottomToolbar.findViewById(R.id.tab_switcher_button_wrapper);
OverviewModeBehaviorWatcher overviewModeWatcher = new OverviewModeBehaviorWatcher(
mActivityTestRule.getActivity().getOverviewModeBehavior(), true, false);
TestThreadUtils.runOnUiThreadBlocking(() -> tabSwitcherButton.callOnClick());
overviewModeWatcher.waitForBehavior();
Assert.assertTrue("Tab switcher should be visible.",
mActivityTestRule.getActivity().getOverviewModeBehavior().overviewVisible());
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment