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

Unified Diff: chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc

Issue 1198313003: Fix the browser match rules. (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc
diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc
index bcfdd4fd0db929d3f96e1165b6141a43fb8c77a0..fd4d451378bd37c8f123c19cf3b02da831caddec 100644
--- a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc
+++ b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc
@@ -29,51 +29,6 @@ typedef ash::test::AshTestBase WindowSizerAshTest;
namespace {
-// A browser window proxy which is able to associate an aura native window with
-// it.
-class TestBrowserWindowAura : public TestBrowserWindow {
- public:
- // |native_window| will still be owned by the caller after the constructor
- // was called.
- explicit TestBrowserWindowAura(aura::Window* native_window)
- : native_window_(native_window) {
- }
- ~TestBrowserWindowAura() override {}
-
- // TestBrowserWindow overrides:
- void Show() override {
- native_window_->Show();
- Activate();
- }
- void Hide() override { native_window_->Hide(); }
- void Activate() override {
- aura::client::GetActivationClient(
- native_window_->GetRootWindow())->ActivateWindow(native_window_.get());
- }
- gfx::NativeWindow GetNativeWindow() const override {
- return native_window_.get();
- }
- gfx::Rect GetBounds() const override { return native_window_->bounds(); }
-
- Browser* browser() { return browser_.get(); }
-
- void CreateBrowser(const Browser::CreateParams& params) {
- Browser::CreateParams create_params = params;
- create_params.window = this;
- browser_.reset(new Browser(create_params));
- if (browser_->is_type_tabbed() || browser_->is_app()) {
- ash::wm::GetWindowState(native_window_.get())->
- set_window_position_managed(true);
- }
- }
-
- private:
- scoped_ptr<Browser> browser_;
- scoped_ptr<aura::Window> native_window_;
-
- DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura);
-};
-
scoped_ptr<TestBrowserWindowAura> CreateTestBrowserWindow(
aura::Window* window,
const gfx::Rect& bounds,
@@ -83,6 +38,11 @@ scoped_ptr<TestBrowserWindowAura> CreateTestBrowserWindow(
scoped_ptr<TestBrowserWindowAura> browser_window(
new TestBrowserWindowAura(window));
browser_window->CreateBrowser(params);
+ if (browser_window->browser()->is_type_tabbed() ||
+ browser_window->browser()->is_app()) {
+ ash::wm::GetWindowState(browser_window->GetNativeWindow())
+ ->set_window_position_managed(true);
+ }
return browser_window.Pass();
}
@@ -483,8 +443,7 @@ TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindows) {
// Creating a popup to make sure it does not interfere with the positioning.
scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow(
- CreateTestWindowInShellWithId(1),
- gfx::Rect(16, 32, 128, 256),
+ CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 128, 256),
Browser::CreateParams(Browser::TYPE_POPUP, profile.get(),
chrome::HOST_DESKTOP_TYPE_ASH)));
@@ -495,6 +454,9 @@ TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindows) {
Browser::CreateParams(Browser::TYPE_POPUP, profile.get(),
chrome::HOST_DESKTOP_TYPE_ASH)));
browser_window->Show();
+ aura::client::GetActivationClient(
+ browser_window->GetNativeWindow()->GetRootWindow())
+ ->ActivateWindow(browser_window->GetNativeWindow());
msw 2015/07/07 18:11:55 nit: i wonder if these activations are actually ne
xdai1 2015/07/08 00:26:21 I tried to delete these activations and it makes n
msw 2015/07/08 01:14:00 yeah, remove them if they're not needed.
{ // Make sure that popups do not get changed.
gfx::Rect window_bounds;
GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(),
@@ -638,22 +600,27 @@ TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) {
CreateTestWindowInShellWithId(0),
gfx::Rect(10, 10, 200, 200),
Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH)));
+ gfx::NativeWindow native_window = browser_window->GetNativeWindow();
browser_window->Show();
- EXPECT_EQ(browser_window->GetNativeWindow()->GetRootWindow(),
- ash::Shell::GetTargetRootWindow());
+ aura::client::GetActivationClient(native_window->GetRootWindow())
+ ->ActivateWindow(native_window);
+ EXPECT_EQ(native_window->GetRootWindow(), ash::Shell::GetTargetRootWindow());
scoped_ptr<BrowserWindow> another_browser_window(CreateTestBrowserWindow(
CreateTestWindowInShellWithId(1),
gfx::Rect(400, 10, 300, 300),
Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH)));
+ gfx::NativeWindow another_native_window =
+ another_browser_window->GetNativeWindow();
another_browser_window->Show();
+ aura::client::GetActivationClient(another_native_window->GetRootWindow())
+ ->ActivateWindow(another_native_window);
// Creating a new window to verify the new placement.
- scoped_ptr<TestBrowserWindowAura> new_browser_window(CreateTestBrowserWindow(
- CreateTestWindowInShellWithId(0),
- gfx::Rect(),
- Browser::CreateParams(profile.get(),
- chrome::HOST_DESKTOP_TYPE_ASH)));
+ scoped_ptr<TestBrowserWindowAura> new_browser_window(
+ CreateTestBrowserWindow(
+ CreateTestWindowInShellWithId(0), gfx::Rect(),
+ Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH)));
// Make sure the primary root is active.
ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(),
@@ -680,7 +647,8 @@ TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) {
browser_window->GetNativeWindow()->SetBoundsInScreen(
gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200),
second_display);
- browser_window->Activate();
+ aura::client::GetActivationClient(native_window->GetRootWindow())
+ ->ActivateWindow(native_window);
EXPECT_NE(ash::Shell::GetPrimaryRootWindow(),
ash::Shell::GetTargetRootWindow());
gfx::Rect window_bounds;
@@ -697,7 +665,8 @@ TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) {
// Activate another window in the primary display and create a new window.
// It should be created in the primary display.
{
- another_browser_window->Activate();
+ aura::client::GetActivationClient(another_native_window->GetRootWindow())
+ ->ActivateWindow(another_native_window);
EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(),
ash::Shell::GetTargetRootWindow());
@@ -726,16 +695,15 @@ TEST_F(WindowSizerAshTest, MAYBE_TestShowState) {
scoped_ptr<TestingProfile> profile(new TestingProfile());
// Creating a browser & window to play with.
- scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow(
- CreateTestWindowInShellWithId(0),
- gfx::Rect(16, 32, 640, 320),
- Browser::CreateParams(Browser::TYPE_TABBED, profile.get(),
- chrome::HOST_DESKTOP_TYPE_ASH)));
+ scoped_ptr<TestBrowserWindowAura> browser_window(
+ CreateTestBrowserWindow(
+ CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320),
+ Browser::CreateParams(Browser::TYPE_TABBED, profile.get(),
+ chrome::HOST_DESKTOP_TYPE_ASH)));
// Create also a popup browser since that behaves different.
scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow(
- CreateTestWindowInShellWithId(1),
- gfx::Rect(16, 32, 640, 320),
+ CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 640, 320),
Browser::CreateParams(Browser::TYPE_POPUP, profile.get(),
chrome::HOST_DESKTOP_TYPE_ASH)));
@@ -784,11 +752,11 @@ TEST_F(WindowSizerAshTest, MAYBE_TestShowState) {
// Now create a top level window and check again for both. Only the tabbed
// window should follow the top level window's state.
// Creating a browser & window to play with.
- scoped_ptr<TestBrowserWindowAura> browser_window2(CreateTestBrowserWindow(
- CreateTestWindowInShellWithId(3),
- gfx::Rect(16, 32, 640, 320),
- Browser::CreateParams(Browser::TYPE_TABBED, profile.get(),
- chrome::HOST_DESKTOP_TYPE_ASH)));
+ scoped_ptr<TestBrowserWindowAura> browser_window2(
+ CreateTestBrowserWindow(
+ CreateTestWindowInShellWithId(3), gfx::Rect(16, 32, 640, 320),
+ Browser::CreateParams(Browser::TYPE_TABBED, profile.get(),
+ chrome::HOST_DESKTOP_TYPE_ASH)));
// A tabbed window should now take the top level window state.
EXPECT_EQ(ui::SHOW_STATE_DEFAULT,
@@ -836,17 +804,16 @@ TEST_F(WindowSizerAshTest, TestShowStateDefaults) {
// Creating a browser & window to play with.
scoped_ptr<TestingProfile> profile(new TestingProfile());
- scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow(
- CreateTestWindowInShellWithId(0),
- gfx::Rect(16, 32, 640, 320),
- Browser::CreateParams(Browser::TYPE_TABBED, profile.get(),
- chrome::HOST_DESKTOP_TYPE_ASH)));
+ scoped_ptr<TestBrowserWindowAura> browser_window(
+ CreateTestBrowserWindow(
+ CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320),
+ Browser::CreateParams(Browser::TYPE_TABBED, profile.get(),
+ chrome::HOST_DESKTOP_TYPE_ASH)));
// Create also a popup browser since that behaves slightly different for
// defaults.
scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow(
- CreateTestWindowInShellWithId(1),
- gfx::Rect(16, 32, 128, 256),
+ CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 128, 256),
Browser::CreateParams(Browser::TYPE_POPUP, profile.get(),
chrome::HOST_DESKTOP_TYPE_ASH)));
@@ -987,8 +954,7 @@ TEST_F(WindowSizerAshTest, TrustedPopupBehavior) {
trusted_popup_create_params.trusted_source = true;
scoped_ptr<TestBrowserWindowAura> trusted_popup(CreateTestBrowserWindow(
- CreateTestWindowInShellWithId(1),
- gfx::Rect(16, 32, 640, 320),
+ CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 640, 320),
trusted_popup_create_params));
// Trusted popup windows should follow the saved show state and ignore the
// last show state.

Powered by Google App Engine
This is Rietveld 408576698