Commit 2361d645 authored by Chong Zhang's avatar Chong Zhang Committed by Commit Bot

NetworkService: Fix HostedAppNonClientFrameViewAshTest for Chrome OS

'HostedAppNonClientFrameViewAshTest.FocusableViews' is failing because
the host resolver was not setup correctly.

The test base only copies host resolver rules and pass them to Network
Service after |SetUpOnMainThread()| has returned, thus we should split
the setup work and put the remaining App setup into a separate
|SetUpHostedApp()| method.

Change-Id: Ia3f7795efc358a5d8b83b9e9baca2a3b9034a894
Reviewed-on: https://chromium-review.googlesource.com/c/1263346
Commit-Queue: Chong Zhang <chongz@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597617}
parent c20cccbe
...@@ -681,7 +681,11 @@ class HostedAppNonClientFrameViewAshTest ...@@ -681,7 +681,11 @@ class HostedAppNonClientFrameViewAshTest
https_server_.AddDefaultHandlers(base::FilePath(kDocRoot)); https_server_.AddDefaultHandlers(base::FilePath(kDocRoot));
ASSERT_TRUE(https_server_.Start()); ASSERT_TRUE(https_server_.Start());
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
}
// |SetUpHostedApp()| must be called after |SetUpOnMainThread()| to make sure
// the Network Service process has been setup properly.
void SetUpHostedApp() {
WebApplicationInfo web_app_info; WebApplicationInfo web_app_info;
web_app_info.app_url = GetAppURL(); web_app_info.app_url = GetAppURL();
web_app_info.scope = GetAppURL().GetWithoutFilename(); web_app_info.scope = GetAppURL().GetWithoutFilename();
...@@ -774,6 +778,7 @@ class HostedAppNonClientFrameViewAshTest ...@@ -774,6 +778,7 @@ class HostedAppNonClientFrameViewAshTest
// bubble anchor adjustment (see |BubbleDialogDelegateView::CreateBubble()|). // bubble anchor adjustment (see |BubbleDialogDelegateView::CreateBubble()|).
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
PageInfoBubblePosition) { PageInfoBubblePosition) {
SetUpHostedApp();
// Resize app window to only take up the left half of the screen. // Resize app window to only take up the left half of the screen.
views::Widget* widget = browser_view_->GetWidget(); views::Widget* widget = browser_view_->GetWidget();
gfx::Size screen_size = gfx::Size screen_size =
...@@ -796,6 +801,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ...@@ -796,6 +801,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
} }
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FocusableViews) { IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FocusableViews) {
SetUpHostedApp();
EXPECT_TRUE(browser_view_->contents_web_view()->HasFocus()); EXPECT_TRUE(browser_view_->contents_web_view()->HasFocus());
browser_view_->GetFocusManager()->AdvanceFocus(false); browser_view_->GetFocusManager()->AdvanceFocus(false);
EXPECT_TRUE(app_menu_button_->HasFocus()); EXPECT_TRUE(app_menu_button_->HasFocus());
...@@ -805,6 +811,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FocusableViews) { ...@@ -805,6 +811,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FocusableViews) {
// Tests that a web app's theme color is set. // Tests that a web app's theme color is set.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ThemeColor) { IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ThemeColor) {
SetUpHostedApp();
aura::Window* window = browser_view_->GetWidget()->GetNativeWindow(); aura::Window* window = browser_view_->GetWidget()->GetNativeWindow();
EXPECT_EQ(GetThemeColor(), window->GetProperty(ash::kFrameActiveColorKey)); EXPECT_EQ(GetThemeColor(), window->GetProperty(ash::kFrameActiveColorKey));
EXPECT_EQ(GetThemeColor(), window->GetProperty(ash::kFrameInactiveColorKey)); EXPECT_EQ(GetThemeColor(), window->GetProperty(ash::kFrameInactiveColorKey));
...@@ -814,6 +821,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ThemeColor) { ...@@ -814,6 +821,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ThemeColor) {
// Make sure that for hosted apps, the height of the frame doesn't exceed the // Make sure that for hosted apps, the height of the frame doesn't exceed the
// height of the caption buttons. // height of the caption buttons.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FrameSize) { IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FrameSize) {
SetUpHostedApp();
const int inset = GetFrameViewAsh(browser_view_)->GetTopInset(false); const int inset = GetFrameViewAsh(browser_view_)->GetTopInset(false);
EXPECT_EQ(inset, EXPECT_EQ(inset,
GetAshLayoutSize(ash::AshLayoutSize::kNonBrowserCaption).height()); GetAshLayoutSize(ash::AshLayoutSize::kNonBrowserCaption).height());
...@@ -825,12 +833,14 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FrameSize) { ...@@ -825,12 +833,14 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FrameSize) {
// provider in this window configuration. // provider in this window configuration.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
ToolbarButtonProvider) { ToolbarButtonProvider) {
SetUpHostedApp();
EXPECT_EQ(browser_view_->toolbar_button_provider(), EXPECT_EQ(browser_view_->toolbar_button_provider(),
hosted_app_button_container_); hosted_app_button_container_);
} }
// Test that the zoom icon appears in the title bar for hosted app windows. // Test that the zoom icon appears in the title bar for hosted app windows.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ZoomIcon) { IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ZoomIcon) {
SetUpHostedApp();
content::WebContents* web_contents = content::WebContents* web_contents =
app_browser_->tab_strip_model()->GetActiveWebContents(); app_browser_->tab_strip_model()->GetActiveWebContents();
zoom::ZoomController* zoom_controller = zoom::ZoomController* zoom_controller =
...@@ -850,6 +860,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ZoomIcon) { ...@@ -850,6 +860,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ZoomIcon) {
// Test that the find icon appears in the title bar for hosted app windows. // Test that the find icon appears in the title bar for hosted app windows.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FindIcon) { IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FindIcon) {
SetUpHostedApp();
PageActionIconView* find_icon = GetPageActionIcon(PageActionIconType::kFind); PageActionIconView* find_icon = GetPageActionIcon(PageActionIconType::kFind);
EXPECT_TRUE(find_icon); EXPECT_TRUE(find_icon);
...@@ -864,6 +875,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FindIcon) { ...@@ -864,6 +875,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, FindIcon) {
// windows. // windows.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
BrowserCommandFocusToolbarAppMenu) { BrowserCommandFocusToolbarAppMenu) {
SetUpHostedApp();
EXPECT_FALSE(app_menu_button_->HasFocus()); EXPECT_FALSE(app_menu_button_->HasFocus());
chrome::ExecuteCommand(app_browser_, IDC_FOCUS_TOOLBAR); chrome::ExecuteCommand(app_browser_, IDC_FOCUS_TOOLBAR);
EXPECT_TRUE(app_menu_button_->HasFocus()); EXPECT_TRUE(app_menu_button_->HasFocus());
...@@ -873,6 +885,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ...@@ -873,6 +885,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
// the app menu button when present in web app windows. // the app menu button when present in web app windows.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
BrowserCommandFocusToolbarGeolocation) { BrowserCommandFocusToolbarGeolocation) {
SetUpHostedApp();
ContentSettingImageView* geolocation_icon = GrantGeolocationPermission(); ContentSettingImageView* geolocation_icon = GrantGeolocationPermission();
EXPECT_FALSE(app_menu_button_->HasFocus()); EXPECT_FALSE(app_menu_button_->HasFocus());
...@@ -887,6 +900,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ...@@ -887,6 +900,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
// Tests that the show app menu command opens the app menu for web app windows. // Tests that the show app menu command opens the app menu for web app windows.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
BrowserCommandShowAppMenu) { BrowserCommandShowAppMenu) {
SetUpHostedApp();
EXPECT_EQ(nullptr, GetAppMenu()); EXPECT_EQ(nullptr, GetAppMenu());
chrome::ExecuteCommand(app_browser_, IDC_SHOW_APP_MENU); chrome::ExecuteCommand(app_browser_, IDC_SHOW_APP_MENU);
EXPECT_NE(nullptr, GetAppMenu()); EXPECT_NE(nullptr, GetAppMenu());
...@@ -896,6 +910,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ...@@ -896,6 +910,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
// windows. // windows.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
BrowserCommandFocusNextPane) { BrowserCommandFocusNextPane) {
SetUpHostedApp();
EXPECT_FALSE(app_menu_button_->HasFocus()); EXPECT_FALSE(app_menu_button_->HasFocus());
chrome::ExecuteCommand(app_browser_, IDC_FOCUS_NEXT_PANE); chrome::ExecuteCommand(app_browser_, IDC_FOCUS_NEXT_PANE);
EXPECT_TRUE(app_menu_button_->HasFocus()); EXPECT_TRUE(app_menu_button_->HasFocus());
...@@ -905,6 +920,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ...@@ -905,6 +920,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
// windows. // windows.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
BrowserCommandFocusPreviousPane) { BrowserCommandFocusPreviousPane) {
SetUpHostedApp();
EXPECT_FALSE(app_menu_button_->HasFocus()); EXPECT_FALSE(app_menu_button_->HasFocus());
chrome::ExecuteCommand(app_browser_, IDC_FOCUS_PREVIOUS_PANE); chrome::ExecuteCommand(app_browser_, IDC_FOCUS_PREVIOUS_PANE);
EXPECT_TRUE(app_menu_button_->HasFocus()); EXPECT_TRUE(app_menu_button_->HasFocus());
...@@ -913,6 +929,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ...@@ -913,6 +929,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
// Tests that a web app's content settings icons can be interacted with. // Tests that a web app's content settings icons can be interacted with.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
ContentSettingIcons) { ContentSettingIcons) {
SetUpHostedApp();
for (auto* view : *content_setting_views_) for (auto* view : *content_setting_views_)
EXPECT_FALSE(view->visible()); EXPECT_FALSE(view->visible());
...@@ -940,6 +957,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, ...@@ -940,6 +957,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
// Tests that a web app's browser action icons can be interacted with. // Tests that a web app's browser action icons can be interacted with.
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, BrowserActions) { IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, BrowserActions) {
SetUpHostedApp();
// Even though 2 are visible in the browser, no extension actions should show. // Even though 2 are visible in the browser, no extension actions should show.
ToolbarActionsBar* toolbar_actions_bar = ToolbarActionsBar* toolbar_actions_bar =
browser_actions_container_->toolbar_actions_bar(); browser_actions_container_->toolbar_actions_bar();
...@@ -965,6 +983,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, BrowserActions) { ...@@ -965,6 +983,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, BrowserActions) {
// Regression test for https://crbug.com/839955 // Regression test for https://crbug.com/839955
IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest,
ActiveStateOfButtonMatchesWidget) { ActiveStateOfButtonMatchesWidget) {
SetUpHostedApp();
ash::FrameCaptionButtonContainerView::TestApi test( ash::FrameCaptionButtonContainerView::TestApi test(
GetFrameViewAsh(browser_view_)->caption_button_container_); GetFrameViewAsh(browser_view_)->caption_button_container_);
EXPECT_TRUE(test.size_button()->paint_as_active()); EXPECT_TRUE(test.size_button()->paint_as_active());
......
...@@ -134,11 +134,6 @@ ...@@ -134,11 +134,6 @@
-SigninProfileAppsPolicyTest.BackgroundPage -SigninProfileAppsPolicyTest.BackgroundPage
-SigninProfileAppsPolicyTest.MultipleApps -SigninProfileAppsPolicyTest.MultipleApps
# Navigation blocked by Safe Browsing.
# e.g. Showing 'Your connection is not private' instead of opening 'app.com'.
-HostedAppNonClientFrameViewAshTest.FocusableViews/material_refresh
-HostedAppNonClientFrameViewAshTest.FocusableViews/material_refresh_touch_optimized
# Flaky with error: `Check failed: (sequence_checker_).CalledOnValidSequence()`. # Flaky with error: `Check failed: (sequence_checker_).CalledOnValidSequence()`.
-DevToolsSanityTest.DisposeEmptyBrowserContext -DevToolsSanityTest.DisposeEmptyBrowserContext
......
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