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

Unified Diff: ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc

Issue 2193783003: Notify WindowStateObserver when minimizing in maximized mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 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
« no previous file with comments | « ash/common/wm/window_state_observer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
diff --git a/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc b/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
index 118ce9e0b9ffad832af78b9b649f2e5a836eb022..d5c1b3ded4544a42118b85fae8b8d49f3b66696a 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
@@ -11,6 +11,7 @@
#include "ash/common/wm/overview/window_selector_controller.h"
#include "ash/common/wm/switchable_windows.h"
#include "ash/common/wm/window_state.h"
+#include "ash/common/wm/window_state_observer.h"
#include "ash/common/wm/wm_event.h"
#include "ash/common/wm_shell.h"
#include "ash/root_window_controller.h"
@@ -35,10 +36,6 @@
namespace ash {
-// TODO(skuhne): These tests are failing on Widows because maximized is there
-// differently handled. Fix this!
-#if !defined(OS_WIN)
-
class MaximizeModeWindowManagerTest : public test::AshTestBase {
public:
MaximizeModeWindowManagerTest() {}
@@ -1592,6 +1589,106 @@ TEST_F(MaximizeModeWindowManagerTest, DontMaximizeDockedWindows) {
EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
}
-#endif // OS_WIN
+namespace {
+
+class TestObserver : public wm::WindowStateObserver {
+ public:
+ TestObserver(){};
+ ~TestObserver() override{};
+
+ // wm::WindowStateObserver:
+ void OnPreWindowStateTypeChange(wm::WindowState* window_state,
+ wm::WindowStateType old_type) override {
+ pre_count_++;
+ last_old_state_ = old_type;
+ }
+
+ void OnPostWindowStateTypeChange(wm::WindowState* window_state,
+ wm::WindowStateType old_type) override {
+ post_count_++;
+ EXPECT_EQ(last_old_state_, old_type);
+ }
+
+ int GetPreCountAndReset() {
+ int r = pre_count_;
+ pre_count_ = 0;
+ return r;
+ }
+
+ int GetPostCountAndReset() {
+ int r = post_count_;
+ post_count_ = 0;
+ return r;
+ }
+
+ wm::WindowStateType GetLastOldStateAndReset() {
+ wm::WindowStateType r = last_old_state_;
+ last_old_state_ = wm::WINDOW_STATE_TYPE_DEFAULT;
+ return r;
+ }
+
+ private:
+ int pre_count_ = 0;
+ int post_count_ = 0;
+ wm::WindowStateType last_old_state_ = wm::WINDOW_STATE_TYPE_DEFAULT;
+
+ DISALLOW_COPY_AND_ASSIGN(TestObserver);
+};
+
+} // namespace
+
+TEST_F(MaximizeModeWindowManagerTest, StateTyepChange) {
+ TestObserver observer;
+ gfx::Rect rect(10, 10, 200, 50);
+ std::unique_ptr<aura::Window> window(
+ CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
+
+ CreateMaximizeModeWindowManager();
+
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ window_state->AddObserver(&observer);
+
+ window->Show();
+ EXPECT_TRUE(window_state->IsMaximized());
+ EXPECT_EQ(0, observer.GetPreCountAndReset());
+ EXPECT_EQ(0, observer.GetPostCountAndReset());
+
+ // Window is already in maximized mode.
+ wm::WMEvent maximize_event(wm::WM_EVENT_MAXIMIZE);
+ window_state->OnWMEvent(&maximize_event);
+ EXPECT_EQ(0, observer.GetPreCountAndReset());
+ EXPECT_EQ(0, observer.GetPostCountAndReset());
+
+ wm::WMEvent fullscreen_event(wm::WM_EVENT_FULLSCREEN);
+ window_state->OnWMEvent(&fullscreen_event);
+ EXPECT_EQ(1, observer.GetPreCountAndReset());
+ EXPECT_EQ(1, observer.GetPostCountAndReset());
+ EXPECT_EQ(wm::WINDOW_STATE_TYPE_MAXIMIZED,
+ observer.GetLastOldStateAndReset());
+
+ window_state->OnWMEvent(&maximize_event);
+ EXPECT_EQ(1, observer.GetPreCountAndReset());
+ EXPECT_EQ(1, observer.GetPostCountAndReset());
+ EXPECT_EQ(wm::WINDOW_STATE_TYPE_FULLSCREEN,
+ observer.GetLastOldStateAndReset());
+
+ wm::WMEvent minimize_event(wm::WM_EVENT_MINIMIZE);
+ window_state->OnWMEvent(&minimize_event);
+ EXPECT_EQ(1, observer.GetPreCountAndReset());
+ EXPECT_EQ(1, observer.GetPostCountAndReset());
+ EXPECT_EQ(wm::WINDOW_STATE_TYPE_MAXIMIZED,
+ observer.GetLastOldStateAndReset());
+
+ wm::WMEvent restore_event(wm::WM_EVENT_NORMAL);
+ window_state->OnWMEvent(&restore_event);
+ EXPECT_EQ(1, observer.GetPreCountAndReset());
+ EXPECT_EQ(1, observer.GetPostCountAndReset());
+ EXPECT_EQ(wm::WINDOW_STATE_TYPE_MINIMIZED,
+ observer.GetLastOldStateAndReset());
+
+ window_state->RemoveObserver(&observer);
+
+ DestroyMaximizeModeWindowManager();
+}
} // namespace ash
« no previous file with comments | « ash/common/wm/window_state_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698