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

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

Issue 2700523004: Remove docked windows entirely in M59. (Closed)
Patch Set: Yet another Rebase ... Created 3 years, 10 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 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const gfx::Size size = w1->bounds().size(); 127 const gfx::Size size = w1->bounds().size();
128 wm::WindowState* window_state = ash::wm::GetWindowState(w1.get()); 128 wm::WindowState* window_state = ash::wm::GetWindowState(w1.get());
129 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get()); 129 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get());
130 130
131 // Explicitly enable window position auto management, and expect it to be 131 // Explicitly enable window position auto management, and expect it to be
132 // restored after drag completes. 132 // restored after drag completes.
133 window_state->set_window_position_managed(true); 133 window_state->set_window_position_managed(true);
134 generator.PressLeftButton(); 134 generator.PressLeftButton();
135 aura::client::WindowMoveClient* move_client = 135 aura::client::WindowMoveClient* move_client =
136 aura::client::GetWindowMoveClient(w1->GetRootWindow()); 136 aura::client::GetWindowMoveClient(w1->GetRootWindow());
137 // generator.PressLeftButton();
138 base::ThreadTaskRunnerHandle::Get()->PostTask( 137 base::ThreadTaskRunnerHandle::Get()->PostTask(
139 FROM_HERE, 138 FROM_HERE,
140 base::Bind(&ContinueAndCompleteDrag, base::Unretained(&generator), 139 base::Bind(&ContinueAndCompleteDrag, base::Unretained(&generator),
141 base::Unretained(window_state), base::Unretained(w1.get()))); 140 base::Unretained(window_state), base::Unretained(w1.get())));
142 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, 141 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
143 move_client->RunMoveLoop(w1.get(), gfx::Vector2d(100, 100), 142 move_client->RunMoveLoop(w1.get(), gfx::Vector2d(100, 100),
144 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); 143 aura::client::WINDOW_MOVE_SOURCE_MOUSE));
145 // Window position auto manage property should be restored to true. 144 // Window position auto manage property should be restored to true.
146 EXPECT_TRUE(window_state->window_position_managed()); 145 EXPECT_TRUE(window_state->window_position_managed());
147 // Position should have been offset by 100,100. 146 // Position should have been offset by 100,100.
(...skipping 13 matching lines...) Expand all
161 move_client->RunMoveLoop(w1.get(), gfx::Vector2d(100, 100), 160 move_client->RunMoveLoop(w1.get(), gfx::Vector2d(100, 100),
162 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); 161 aura::client::WINDOW_MOVE_SOURCE_MOUSE));
163 // Window position auto manage property should be restored to true. 162 // Window position auto manage property should be restored to true.
164 EXPECT_FALSE(window_state->window_position_managed()); 163 EXPECT_FALSE(window_state->window_position_managed());
165 // Position should have been offset by 100,100. 164 // Position should have been offset by 100,100.
166 EXPECT_EQ("200,200", w1->bounds().origin().ToString()); 165 EXPECT_EQ("200,200", w1->bounds().origin().ToString());
167 // Size should remain the same. 166 // Size should remain the same.
168 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString()); 167 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
169 } 168 }
170 169
171 namespace {
172
173 class CancelDragObserver : public aura::WindowObserver {
174 public:
175 CancelDragObserver() {}
176 ~CancelDragObserver() override {}
177
178 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override {
179 aura::client::CaptureClient* client =
180 aura::client::GetCaptureClient(params.target->GetRootWindow());
181 client->SetCapture(nullptr);
182 }
183
184 private:
185 DISALLOW_COPY_AND_ASSIGN(CancelDragObserver);
186 };
187
188 } // namespace
189
190 // Cancelling drag while starting window drag should not crash. 170 // Cancelling drag while starting window drag should not crash.
191 TEST_F(ToplevelWindowEventHandlerTest, CancelWhileDragStart) { 171 TEST_F(ToplevelWindowEventHandlerTest, CancelWhileDragStart) {
192 std::unique_ptr<aura::Window> w1(CreateWindow(HTCAPTION)); 172 std::unique_ptr<aura::Window> w1(CreateWindow(HTCAPTION));
193 CancelDragObserver observer;
194 w1->AddObserver(&observer);
195 gfx::Point origin = w1->bounds().origin(); 173 gfx::Point origin = w1->bounds().origin();
196 DragFromCenterBy(w1.get(), 100, 100); 174 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get());
175 generator.PressLeftButton();
176 generator.MoveMouseBy(100, 100);
177 generator.PressKey(ui::VKEY_ESCAPE, 0);
178 generator.ReleaseLeftButton();
197 EXPECT_EQ(origin, w1->bounds().origin()); 179 EXPECT_EQ(origin, w1->bounds().origin());
198 w1->RemoveObserver(&observer);
199 } 180 }
oshima 2017/02/23 02:21:02 Is this test still meaningful? I guess this was to
afakhry 2017/02/23 18:08:54 It seems we still have reparenting with panels: ht
200 181
201 TEST_F(ToplevelWindowEventHandlerTest, BottomRight) { 182 TEST_F(ToplevelWindowEventHandlerTest, BottomRight) {
202 std::unique_ptr<aura::Window> w1(CreateWindow(HTBOTTOMRIGHT)); 183 std::unique_ptr<aura::Window> w1(CreateWindow(HTBOTTOMRIGHT));
203 gfx::Point position = w1->bounds().origin(); 184 gfx::Point position = w1->bounds().origin();
204 DragFromCenterBy(w1.get(), 100, 100); 185 DragFromCenterBy(w1.get(), 100, 100);
205 // Position should not have changed. 186 // Position should not have changed.
206 EXPECT_EQ(position.ToString(), w1->bounds().origin().ToString()); 187 EXPECT_EQ(position.ToString(), w1->bounds().origin().ToString());
207 // Size should have increased by 100,100. 188 // Size should have increased by 100,100.
208 EXPECT_EQ(gfx::Size(200, 200).ToString(), w1->bounds().size().ToString()); 189 EXPECT_EQ(gfx::Size(200, 200).ToString(), w1->bounds().size().ToString());
209 } 190 }
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 display_manager()->SetLayoutForCurrentDisplays(builder.Build()); 804 display_manager()->SetLayoutForCurrentDisplays(builder.Build());
824 805
825 const gfx::Size initial_window_size(330, 230); 806 const gfx::Size initial_window_size(330, 230);
826 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegateAndType( 807 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegateAndType(
827 new TestWindowDelegate(HTCAPTION), ui::wm::WINDOW_TYPE_NORMAL, 0, 808 new TestWindowDelegate(HTCAPTION), ui::wm::WINDOW_TYPE_NORMAL, 0,
828 gfx::Rect(initial_window_size))); 809 gfx::Rect(initial_window_size)));
829 810
830 // Snap the window to the right. 811 // Snap the window to the right.
831 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 812 wm::WindowState* window_state = wm::GetWindowState(w1.get());
832 ASSERT_TRUE(window_state->CanSnap()); 813 ASSERT_TRUE(window_state->CanSnap());
833 const wm::WMEvent event(wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT); 814 const wm::WMEvent event(wm::WM_EVENT_CYCLE_SNAP_RIGHT);
834 window_state->OnWMEvent(&event); 815 window_state->OnWMEvent(&event);
835 ASSERT_TRUE(window_state->IsSnapped()); 816 ASSERT_TRUE(window_state->IsSnapped());
836 817
837 // Drag the window to the secondary display. 818 // Drag the window to the secondary display.
838 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get()); 819 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get());
839 generator.DragMouseTo(472, -462); 820 generator.DragMouseTo(472, -462);
840 821
841 // Expect the window is no longer snapped and its size was restored to the 822 // Expect the window is no longer snapped and its size was restored to the
842 // initial size. 823 // initial size.
843 EXPECT_FALSE(window_state->IsSnapped()); 824 EXPECT_FALSE(window_state->IsSnapped());
844 EXPECT_EQ(initial_window_size.ToString(), w1->bounds().size().ToString()); 825 EXPECT_EQ(initial_window_size.ToString(), w1->bounds().size().ToString());
845 826
846 // The window is now fully contained in the secondary display. 827 // The window is now fully contained in the secondary display.
847 EXPECT_TRUE(display_manager()->GetSecondaryDisplay().bounds().Contains( 828 EXPECT_TRUE(display_manager()->GetSecondaryDisplay().bounds().Contains(
848 w1->GetBoundsInScreen())); 829 w1->GetBoundsInScreen()));
849 } 830 }
850 831
851 // Showing the resize shadows when the mouse is over the window edges is tested 832 // Showing the resize shadows when the mouse is over the window edges is tested
852 // in resize_shadow_and_cursor_test.cc 833 // in resize_shadow_and_cursor_test.cc
853 834
854 } // namespace test 835 } // namespace test
855 } // namespace ash 836 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698