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

Side by Side Diff: ash/wm/toplevel_window_event_handler_unittest.cc

Issue 2540013005: Reland of Reenable Tabdragging tests failing because of IsWindowPositionManaged() (Closed)
Patch Set: Applying the fix Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/toplevel_window_event_handler.h" 5 #include "ash/wm/toplevel_window_event_handler.h"
6 6
7 #include "ash/common/wm/window_state.h" 7 #include "ash/common/wm/window_state.h"
8 #include "ash/common/wm/wm_event.h" 8 #include "ash/common/wm/wm_event.h"
9 #include "ash/common/wm/workspace_controller.h" 9 #include "ash/common/wm/workspace_controller.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 TouchDragFromCenterBy(w1.get(), 100, 100); 110 TouchDragFromCenterBy(w1.get(), 100, 100);
111 // Position should have been offset by 100,100. 111 // Position should have been offset by 100,100.
112 EXPECT_EQ("200,200", w1->bounds().origin().ToString()); 112 EXPECT_EQ("200,200", w1->bounds().origin().ToString());
113 // Size should not have. 113 // Size should not have.
114 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString()); 114 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
115 } 115 }
116 116
117 namespace { 117 namespace {
118 118
119 void ContinueAndCompleteDrag(ui::test::EventGenerator* generator,
120 wm::WindowState* window_state,
121 aura::Window* window) {
122 ASSERT_TRUE(window->HasCapture());
123 ASSERT_FALSE(window_state->window_position_managed());
124 generator->DragMouseBy(100, 100);
125 generator->ReleaseLeftButton();
126 }
127
128 } // namespace
129
130 // Tests dragging restores expected window position auto manage property
131 // correctly.
132 TEST_F(ToplevelWindowEventHandlerTest, WindowPositionAutoManagement) {
133 std::unique_ptr<aura::Window> w1(CreateWindow(HTNOWHERE));
134 const gfx::Size size = w1->bounds().size();
135 wm::WindowState* window_state = ash::wm::GetWindowState(w1.get());
136 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get());
137
138 // Explicitly enable window position auto management, and expect it to be
139 // restored after drag completes.
140 window_state->set_window_position_managed(true);
141 generator.PressLeftButton();
142 aura::client::WindowMoveClient* move_client =
143 aura::client::GetWindowMoveClient(w1->GetRootWindow());
144 // generator.PressLeftButton();
145 base::ThreadTaskRunnerHandle::Get()->PostTask(
146 FROM_HERE,
147 base::Bind(&ContinueAndCompleteDrag, base::Unretained(&generator),
148 base::Unretained(window_state), base::Unretained(w1.get())));
149 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
150 move_client->RunMoveLoop(w1.get(), gfx::Vector2d(100, 100),
151 aura::client::WINDOW_MOVE_SOURCE_MOUSE));
152 // Window position auto manage property should be restored to true.
153 EXPECT_TRUE(window_state->window_position_managed());
154 // Position should have been offset by 100,100.
155 EXPECT_EQ("100,100", w1->bounds().origin().ToString());
156 // Size should remain the same.
157 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
158
159 // Explicitly disable window position auto management, and expect it to be
160 // restored after drag completes.
161 window_state->set_window_position_managed(false);
162 generator.PressLeftButton();
163 base::ThreadTaskRunnerHandle::Get()->PostTask(
164 FROM_HERE,
165 base::Bind(&ContinueAndCompleteDrag, base::Unretained(&generator),
166 base::Unretained(window_state), base::Unretained(w1.get())));
167 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
168 move_client->RunMoveLoop(w1.get(), gfx::Vector2d(100, 100),
169 aura::client::WINDOW_MOVE_SOURCE_MOUSE));
170 // Window position auto manage property should be restored to true.
171 EXPECT_FALSE(window_state->window_position_managed());
172 // Position should have been offset by 100,100.
173 EXPECT_EQ("200,200", w1->bounds().origin().ToString());
174 // Size should remain the same.
175 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
176 }
177
178 namespace {
179
119 class CancelDragObserver : public aura::WindowObserver { 180 class CancelDragObserver : public aura::WindowObserver {
120 public: 181 public:
121 CancelDragObserver() {} 182 CancelDragObserver() {}
122 ~CancelDragObserver() override {} 183 ~CancelDragObserver() override {}
123 184
124 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override { 185 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override {
125 aura::client::CaptureClient* client = 186 aura::client::CaptureClient* client =
126 aura::client::GetCaptureClient(params.target->GetRootWindow()); 187 aura::client::GetCaptureClient(params.target->GetRootWindow());
127 client->SetCapture(nullptr); 188 client->SetCapture(nullptr);
128 } 189 }
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 // The window is now fully contained in the secondary display. 868 // The window is now fully contained in the secondary display.
808 EXPECT_TRUE(display_manager()->GetSecondaryDisplay().bounds().Contains( 869 EXPECT_TRUE(display_manager()->GetSecondaryDisplay().bounds().Contains(
809 w1->GetBoundsInScreen())); 870 w1->GetBoundsInScreen()));
810 } 871 }
811 872
812 // Showing the resize shadows when the mouse is over the window edges is tested 873 // Showing the resize shadows when the mouse is over the window edges is tested
813 // in resize_shadow_and_cursor_test.cc 874 // in resize_shadow_and_cursor_test.cc
814 875
815 } // namespace test 876 } // namespace test
816 } // namespace ash 877 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/toplevel_window_event_handler.cc ('k') | chrome/browser/ui/views/tabs/tab_drag_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698