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

Unified Diff: ash/wm/workspace/workspace_layout_manager_unittest.cc

Issue 100903002: Ignore fullscreen windows which are behind other windows for fullscreen mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test that WorkspaceLayoutManager correctly notifies on fullscreen changes. Created 7 years 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: ash/wm/workspace/workspace_layout_manager_unittest.cc
diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc
index 4302f1dc44f9bdb6093f59bc2a286b2d743ff77a..e8625c6102a8db61842ad13d130c7eca78783267 100644
--- a/ash/wm/workspace/workspace_layout_manager_unittest.cc
+++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc
@@ -11,6 +11,7 @@
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
+#include "ash/shell_observer.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
@@ -47,6 +48,36 @@ class MaximizeDelegateView : public views::WidgetDelegateView {
DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView);
};
+class TestShellObserver : public ShellObserver {
+ public:
+ TestShellObserver() : call_count_(0),
+ is_fullscreen_(false) {
+ Shell::GetInstance()->AddShellObserver(this);
+ }
+
+ virtual ~TestShellObserver() {
+ Shell::GetInstance()->RemoveShellObserver(this);
+ }
+
+ virtual void OnFullscreenStateChanged(bool is_fullscreen,
+ aura::Window* root_window) OVERRIDE {
+ call_count_++;
+ is_fullscreen_ = is_fullscreen;
+ }
+
+ int call_count() {
+ return call_count_;
+ }
+
+ bool is_fullscreen() {
+ return is_fullscreen_;
+ }
+
+ private:
+ int call_count_;
+ bool is_fullscreen_;
+};
+
} // namespace
typedef test::AshTestBase WorkspaceLayoutManagerTest;
@@ -407,4 +438,33 @@ TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) {
window->bounds().ToString());
}
+TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) {
+ TestShellObserver observer;
+ scoped_ptr<aura::Window> window1(
+ CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
+ scoped_ptr<aura::Window> window2(
+ CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
+ wm::WindowState* window_state1 = wm::GetWindowState(window1.get());
+ wm::WindowState* window_state2 = wm::GetWindowState(window2.get());
+ window_state2->Activate();
+
+ window_state2->ToggleFullscreen();
+ EXPECT_EQ(1, observer.call_count());
+ EXPECT_TRUE(observer.is_fullscreen());
+
+ // When window1 moves to the front the fullscreen state should change.
+ window_state1->Activate();
+ EXPECT_EQ(2, observer.call_count());
+ EXPECT_FALSE(observer.is_fullscreen());
+
+ // It should change back if window2 becomes active again.
+ window_state2->Activate();
+ EXPECT_EQ(3, observer.call_count());
+ EXPECT_TRUE(observer.is_fullscreen());
+
+ window_state2->ToggleFullscreen();
+ EXPECT_EQ(4, observer.call_count());
+ EXPECT_FALSE(observer.is_fullscreen());
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698