Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc

Issue 1240393005: [Docking] Restores docked state for tab-less browser windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/window_sizer/window_sizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include "chrome/browser/ui/browser_commands.h" 7 #include "chrome/browser/ui/browser_commands.h"
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
9 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "ui/views/focus/focus_manager.h" 10 #include "ui/views/focus/focus_manager.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // remembered for tabbed browser windows. 57 // remembered for tabbed browser windows.
58 IN_PROC_BROWSER_TEST_P(BrowserViewTestParam, BrowserRemembersDockedState) { 58 IN_PROC_BROWSER_TEST_P(BrowserViewTestParam, BrowserRemembersDockedState) {
59 // Open a new browser window (app or tabbed depending on a parameter). 59 // Open a new browser window (app or tabbed depending on a parameter).
60 bool test_app = TestApp(); 60 bool test_app = TestApp();
61 Browser::CreateParams params = 61 Browser::CreateParams params =
62 test_app ? Browser::CreateParams::CreateForApp( 62 test_app ? Browser::CreateParams::CreateForApp(
63 "test_browser_app", true /* trusted_source */, gfx::Rect(), 63 "test_browser_app", true /* trusted_source */, gfx::Rect(),
64 browser()->profile(), browser()->host_desktop_type()) 64 browser()->profile(), browser()->host_desktop_type())
65 : Browser::CreateParams(browser()->profile(), 65 : Browser::CreateParams(browser()->profile(),
66 browser()->host_desktop_type()); 66 browser()->host_desktop_type());
67 params.initial_show_state = ui::SHOW_STATE_NORMAL; 67 params.initial_show_state = ui::SHOW_STATE_DEFAULT;
68 bool is_ash = browser()->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH; 68 bool is_ash = browser()->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH;
69 // Default |browser()| is not used by this test. 69 // Default |browser()| is not used by this test.
70 browser()->window()->Close(); 70 browser()->window()->Close();
71 71
72 // Create a new app browser 72 // Create a new app browser
73 Browser* browser = new Browser(params); 73 Browser* browser = new Browser(params);
74 ASSERT_TRUE(browser); 74 ASSERT_TRUE(browser);
75 gfx::NativeWindow window = browser->window()->GetNativeWindow(); 75 gfx::NativeWindow window = browser->window()->GetNativeWindow();
76 gfx::Rect original_bounds(gfx::Rect(150, 250, 350, 100)); 76 gfx::Rect original_bounds(gfx::Rect(150, 250, 350, 100));
77 window->SetBounds(original_bounds); 77 window->SetBounds(original_bounds);
78 window->Show(); 78 window->Show();
79 // Dock the browser window using |kShowStateKey| property. 79 // Dock the browser window using |kShowStateKey| property.
80 gfx::Rect work_area = gfx::Screen::GetScreenFor(window) 80 gfx::Rect work_area = gfx::Screen::GetScreenFor(window)
81 ->GetDisplayNearestPoint(window->bounds().origin()) 81 ->GetDisplayNearestPoint(window->bounds().origin())
82 .work_area(); 82 .work_area();
83 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED); 83 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED);
84 84
85 // Saved placement should reflect docked state (for app windows only in Ash). 85 // Saved placement should reflect docked state (for app windows only in Ash).
86 gfx::Rect bounds; 86 gfx::Rect bounds;
87 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; 87 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT;
88 const views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); 88 const views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
89 widget->widget_delegate()->GetSavedWindowPlacement(widget, &bounds, 89 widget->widget_delegate()->GetSavedWindowPlacement(widget, &bounds,
90 &show_state); 90 &show_state);
91 EXPECT_EQ(is_ash && test_app ? ui::SHOW_STATE_DOCKED : ui::SHOW_STATE_NORMAL, 91 EXPECT_EQ(is_ash && test_app ? ui::SHOW_STATE_DOCKED : ui::SHOW_STATE_DEFAULT,
92 show_state); 92 show_state);
93 // Docking is only relevant on Ash desktop. 93 // Docking is only relevant on Ash desktop.
94 if (!is_ash) 94 if (!is_ash)
95 return; 95 return;
96 96
97 // Saved placement should reflect restore bounds. 97 // Saved placement should reflect restore bounds.
98 ASSERT_NE(nullptr, window->GetProperty(aura::client::kRestoreBoundsKey)); 98 ASSERT_NE(nullptr, window->GetProperty(aura::client::kRestoreBoundsKey));
99 original_bounds = *window->GetProperty(aura::client::kRestoreBoundsKey); 99 original_bounds = *window->GetProperty(aura::client::kRestoreBoundsKey);
100 gfx::Rect expected_bounds = work_area; 100 gfx::Rect expected_bounds = work_area;
101 expected_bounds.ClampToCenteredSize(original_bounds.size()); 101 expected_bounds.ClampToCenteredSize(original_bounds.size());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 window = browser->window()->GetNativeWindow(); 147 window = browser->window()->GetNativeWindow();
148 EXPECT_EQ(expected_bounds.ToString(), window->GetTargetBounds().ToString()); 148 EXPECT_EQ(expected_bounds.ToString(), window->GetTargetBounds().ToString());
149 EXPECT_EQ(ui::SHOW_STATE_NORMAL, 149 EXPECT_EQ(ui::SHOW_STATE_NORMAL,
150 window->GetProperty(aura::client::kShowStateKey)); 150 window->GetProperty(aura::client::kShowStateKey));
151 } 151 }
152 152
153 INSTANTIATE_TEST_CASE_P(BrowserViewTestTabbedOrApp, 153 INSTANTIATE_TEST_CASE_P(BrowserViewTestTabbedOrApp,
154 BrowserViewTestParam, 154 BrowserViewTestParam,
155 testing::Bool()); 155 testing::Bool());
156 #endif 156 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/window_sizer/window_sizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698