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

Unified Diff: athena/wm/window_manager_unittest.cc

Issue 668513003: Selecting an app window from the overview mode maximizes the window only if it's maximizable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Acknowledging the code review and fixing other relevant bugs related to the fix and split mode. Created 6 years, 2 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: athena/wm/window_manager_unittest.cc
diff --git a/athena/wm/window_manager_unittest.cc b/athena/wm/window_manager_unittest.cc
index 7adda80235df558423255925974b2f3120a4c952..52b7b0afa2894eac94c4786b18aa34f0b329ed76 100644
--- a/athena/wm/window_manager_unittest.cc
+++ b/athena/wm/window_manager_unittest.cc
@@ -10,6 +10,7 @@
#include "athena/wm/split_view_controller.h"
#include "athena/wm/test/window_manager_impl_test_api.h"
#include "athena/wm/window_manager_impl.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window.h"
@@ -99,6 +100,59 @@ TEST_F(WindowManagerTest, OverviewToSplitViewMode) {
EXPECT_FALSE(w1->IsVisible());
}
+TEST_F(WindowManagerTest, OnSelectWindow) {
+ test::WindowManagerImplTestApi wm_api;
+ aura::test::TestWindowDelegate delegate1;
+ aura::test::TestWindowDelegate delegate2;
+ aura::test::TestWindowDelegate delegate3;
+
+ // (w1): A window that sets a maximum size
+ delegate1.set_maximum_size(gfx::Size(300, 200));
+ scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate1));
+ w1->SetBounds(gfx::Rect(0, 0, 300, 200));
+
+ // (w2): A window that doesn't set a max size and is maximizable
+ scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate2));
+ w2->SetBounds(gfx::Rect(0, 0, 300, 200));
+ w2->SetProperty(aura::client::kCanMaximizeKey, true);
+
+ // (w3): A window that doesn't set a max size but is NOT maximizable
+ scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate3));
+ w3->SetBounds(gfx::Rect(0, 0, 300, 200));
+ w3->SetProperty(aura::client::kCanMaximizeKey, false);
+
+ const gfx::Size old_bounds1 = w1->GetTargetBounds().size();
+ const gfx::Size old_bounds2 = w2->GetTargetBounds().size();
+ const gfx::Size old_bounds3 = w3->GetTargetBounds().size();
+ const gfx::Size work_area =
+ gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
+
+ // Select w1, which has a max size, in the overview mode and make sure it's
+ // not maximized.
+ WindowManager::Get()->EnterOverview();
+ WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
+ overview_delegate->OnSelectWindow(w1.get());
+ const gfx::Size new_bounds1 = w1->GetTargetBounds().size();
+ EXPECT_EQ(new_bounds1.ToString(), old_bounds1.ToString());
+ EXPECT_NE(work_area.ToString(), new_bounds1.ToString());
+
+ // Select w2, which has no max size & can be maximized, in the overview
+ // mode and make sure it's actually maximized.
+ WindowManager::Get()->EnterOverview();
+ overview_delegate->OnSelectWindow(w2.get());
+ const gfx::Size new_bounds2 = w2->GetTargetBounds().size();
+ EXPECT_NE(new_bounds2.ToString(), old_bounds2.ToString());
+ EXPECT_EQ(work_area.ToString(), new_bounds2.ToString());
+
+ // Select w3, which has no max size & cannot be maximized, in the overview
+ // mode and make sure it's not maximized.
+ WindowManager::Get()->EnterOverview();
+ overview_delegate->OnSelectWindow(w3.get());
+ const gfx::Size new_bounds3 = w3->GetTargetBounds().size();
+ EXPECT_EQ(new_bounds3.ToString(), old_bounds3.ToString());
+ EXPECT_NE(work_area.ToString(), new_bounds3.ToString());
+}
+
TEST_F(WindowManagerTest, NewWindowFromOverview) {
aura::test::TestWindowDelegate delegate;
scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
@@ -350,8 +404,11 @@ TEST_F(WindowManagerTest, SplitModeActivationByShortcut) {
wm_api.wm()->ToggleSplitView();
EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
- EXPECT_EQ(width, w1->bounds().width());
+ // w2 is the top window, it should be resized to max width and must be visible
+ // w1 should be hidden.
EXPECT_EQ(width, w2->bounds().width());
+ EXPECT_TRUE(w2->IsVisible());
+ EXPECT_FALSE(w1->IsVisible());
oshima 2014/10/24 18:39:56 can you activate w1 and check if it's properly res
afakhry 2014/10/25 00:35:08 Done.
}
TEST_F(WindowManagerTest, OverviewModeFromSplitMode) {

Powered by Google App Engine
This is Rietveld 408576698