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

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: Changed the previous fix according to suggested review 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
« athena/wm/window_manager_impl.cc ('K') | « athena/wm/window_manager_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..30dfae8f71de69e47c3f38d0bf57386d5382e9d4 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,67 @@ 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);
+
+ // Get the current bounds
oshima 2014/10/23 01:05:46 nit: you don't need this comment as it's obvious
afakhry 2014/10/24 02:09:45 Acknowledged.
+ const gfx::Size old_bounds1 = w1->GetTargetBounds().size();
+ const gfx::Size old_bounds2 = w2->GetTargetBounds().size();
+ const gfx::Size old_bounds3 = w3->GetTargetBounds().size();
+
+ // Get the screen bounds
oshima 2014/10/23 01:05:46 ditto
afakhry 2014/10/24 02:09:45 Acknowledged.
+ const gfx::Size work_area =
+ gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
+
+ // Enter the overview mode and select window 1 (has a max size).
oshima 2014/10/23 01:05:46 This is probably simpler. // Select w1 which has
afakhry 2014/10/24 02:09:45 Acknowledged.
+ WindowManager::Get()->EnterOverview();
+ WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
+ overview_delegate->OnSelectWindow(w1.get());
+
+ // Test that the window was not maximized
oshima 2014/10/23 01:05:46 and remove this comment.
afakhry 2014/10/24 02:09:45 Acknowledged.
+ const gfx::Size new_bounds1 = w1->GetTargetBounds().size();
+ EXPECT_EQ(new_bounds1, old_bounds1);
+ EXPECT_NE(work_area, new_bounds1);
oshima 2014/10/23 01:05:46 can you check using string (ToString)? That'll giv
afakhry 2014/10/24 02:09:45 Acknowledged.
+
+ // Enter the overview mode and select window 2 (has no max size & can be
+ // maximized).
oshima 2014/10/23 01:05:46 ditto
afakhry 2014/10/24 02:09:45 Acknowledged.
+ WindowManager::Get()->EnterOverview();
+ overview_delegate->OnSelectWindow(w2.get());
+
+ // Test that the window was actually maximized.
+ const gfx::Size new_bounds2 = w2->GetTargetBounds().size();
+ EXPECT_NE(new_bounds2, old_bounds2);
+ EXPECT_EQ(work_area, new_bounds2);
+
+ // Enter the overview mode and select window 3 (has no max size but cannot be
+ // maximized).
oshima 2014/10/23 01:05:46 ditto
afakhry 2014/10/24 02:09:45 Acknowledged.
+ WindowManager::Get()->EnterOverview();
+ overview_delegate->OnSelectWindow(w3.get());
+
+ // Test that the window was not maximized
+ const gfx::Size new_bounds3 = w3->GetTargetBounds().size();
+ EXPECT_EQ(new_bounds3, old_bounds3);
+ EXPECT_NE(work_area, new_bounds3);
+}
+
TEST_F(WindowManagerTest, NewWindowFromOverview) {
aura::test::TestWindowDelegate delegate;
scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
« athena/wm/window_manager_impl.cc ('K') | « athena/wm/window_manager_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698