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

Side by Side Diff: ash/wm/panels/panel_window_resizer_unittest.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « ash/wm/panels/panel_window_event_handler.cc ('k') | ash/wm/power_button_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/common/wm/panels/panel_window_resizer.h" 5 #include "ash/common/wm/panels/panel_window_resizer.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/shelf/shelf_model.h" 8 #include "ash/common/shelf/shelf_model.h"
9 #include "ash/common/shelf/shelf_types.h" 9 #include "ash/common/shelf/shelf_types.h"
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // The panel should be reattached and have snapped to the launcher. 125 // The panel should be reattached and have snapped to the launcher.
126 EXPECT_TRUE(window_state->panel_attached()); 126 EXPECT_TRUE(window_state->panel_attached());
127 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); 127 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x());
128 EXPECT_EQ(initial_bounds.y(), window->GetBoundsInScreen().y()); 128 EXPECT_EQ(initial_bounds.y(), window->GetBoundsInScreen().y());
129 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 129 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
130 } 130 }
131 131
132 void TestWindowOrder(const std::vector<aura::Window*>& window_order) { 132 void TestWindowOrder(const std::vector<aura::Window*>& window_order) {
133 int panel_index = model_->FirstPanelIndex(); 133 int panel_index = model_->FirstPanelIndex();
134 EXPECT_EQ((int)(panel_index + window_order.size()), model_->item_count()); 134 EXPECT_EQ((int)(panel_index + window_order.size()), model_->item_count());
135 for (std::vector<aura::Window*>::const_iterator iter = 135 for (std::vector<aura::Window *>::const_iterator
136 window_order.begin(); iter != window_order.end(); 136 iter = window_order.begin();
137 ++iter, ++panel_index) { 137 iter != window_order.end(); ++iter, ++panel_index) {
138 ShelfID id = GetShelfIDForWindow(*iter); 138 ShelfID id = GetShelfIDForWindow(*iter);
139 EXPECT_EQ(id, model_->items()[panel_index].id); 139 EXPECT_EQ(id, model_->items()[panel_index].id);
140 } 140 }
141 } 141 }
142 142
143 // Test dragging panel window along the shelf and verify that panel icons 143 // Test dragging panel window along the shelf and verify that panel icons
144 // are reordered appropriately. 144 // are reordered appropriately.
145 void DragAlongShelfReorder(int dx, int dy) { 145 void DragAlongShelfReorder(int dx, int dy) {
146 gfx::Point origin(0, 0); 146 gfx::Point origin(0, 0);
147 std::unique_ptr<aura::Window> w1(CreatePanelWindow(origin)); 147 std::unique_ptr<aura::Window> w1(CreatePanelWindow(origin));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 protected: 221 protected:
222 ui::wm::WindowType transient_window_type_; 222 ui::wm::WindowType transient_window_type_;
223 223
224 private: 224 private:
225 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTransientTest); 225 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTransientTest);
226 }; 226 };
227 227
228 // Verifies a window can be dragged from the panel and detached and then 228 // Verifies a window can be dragged from the panel and detached and then
229 // reattached. 229 // reattached.
230 TEST_F(PanelWindowResizerTest, PanelDetachReattachBottom) { 230 TEST_F(PanelWindowResizerTest, PanelDetachReattachBottom) {
231 if (!SupportsHostWindowResize()) 231 if (!SupportsHostWindowResize())
232 return; 232 return;
233 233
234 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 234 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
235 DetachReattachTest(window.get(), 0, -1); 235 DetachReattachTest(window.get(), 0, -1);
236 } 236 }
237 237
238 TEST_F(PanelWindowResizerTest, PanelDetachReattachLeft) { 238 TEST_F(PanelWindowResizerTest, PanelDetachReattachLeft) {
239 if (!SupportsHostWindowResize()) 239 if (!SupportsHostWindowResize())
240 return; 240 return;
241 241
242 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_LEFT); 242 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_LEFT);
243 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 243 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
244 DetachReattachTest(window.get(), 1, 0); 244 DetachReattachTest(window.get(), 1, 0);
245 } 245 }
246 246
247 TEST_F(PanelWindowResizerTest, PanelDetachReattachRight) { 247 TEST_F(PanelWindowResizerTest, PanelDetachReattachRight) {
248 if (!SupportsHostWindowResize()) 248 if (!SupportsHostWindowResize())
249 return; 249 return;
250 250
251 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_RIGHT); 251 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_RIGHT);
252 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 252 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
253 DetachReattachTest(window.get(), -1, 0); 253 DetachReattachTest(window.get(), -1, 0);
254 } 254 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 EXPECT_TRUE(wm::GetWindowState(fullscreen.get())->IsFullscreen()); 413 EXPECT_TRUE(wm::GetWindowState(fullscreen.get())->IsFullscreen());
414 414
415 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 415 gfx::Rect initial_bounds = window->GetBoundsInScreen();
416 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 416 EXPECT_EQ(root_windows[0], window->GetRootWindow());
417 417
418 // Activate and drag the window to the other display's launcher. 418 // Activate and drag the window to the other display's launcher.
419 wm::GetWindowState(window.get())->Activate(); 419 wm::GetWindowState(window.get())->Activate();
420 DragStart(window.get()); 420 DragStart(window.get());
421 DragMove(500, 250); 421 DragMove(500, 250);
422 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); 422 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
423 EXPECT_GT(window->GetBoundsInScreen().y(), 423 EXPECT_GT(window->GetBoundsInScreen().y(), initial_bounds.y() + 200);
424 initial_bounds.y() + 200);
425 DragEnd(); 424 DragEnd();
426 425
427 // When dropped should move to second display's panel container. 426 // When dropped should move to second display's panel container.
428 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 427 EXPECT_EQ(root_windows[1], window->GetRootWindow());
429 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); 428 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached());
430 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 429 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
431 EXPECT_TRUE(window->IsVisible()); 430 EXPECT_TRUE(window->IsVisible());
432 EXPECT_TRUE(wm::GetWindowState(window.get())->IsActive()); 431 EXPECT_TRUE(wm::GetWindowState(window.get())->IsActive());
433 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); 432 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y());
434 } 433 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 CreateTestWindowInShellWithDelegateAndType( 502 CreateTestWindowInShellWithDelegateAndType(
504 NULL, transient_window_type_, 0, gfx::Rect(20, 20, 150, 40))); 503 NULL, transient_window_type_, 0, gfx::Rect(20, 20, 150, 40)));
505 ::wm::AddTransientChild(window.get(), child.get()); 504 ::wm::AddTransientChild(window.get(), child.get());
506 if (window->parent() != child->parent()) 505 if (window->parent() != child->parent())
507 window->parent()->AddChild(child.get()); 506 window->parent()->AddChild(child.get());
508 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); 507 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get()));
509 508
510 // Drag the child to the shelf. Its new position should not be overridden. 509 // Drag the child to the shelf. Its new position should not be overridden.
511 const gfx::Rect attached_bounds(window->GetBoundsInScreen()); 510 const gfx::Rect attached_bounds(window->GetBoundsInScreen());
512 const int dy = window->GetBoundsInScreen().bottom() - 511 const int dy = window->GetBoundsInScreen().bottom() -
513 child->GetBoundsInScreen().bottom(); 512 child->GetBoundsInScreen().bottom();
514 DragStart(child.get()); 513 DragStart(child.get());
515 DragMove(50, dy); 514 DragMove(50, dy);
516 // While moving the transient child window should be in the panel container. 515 // While moving the transient child window should be in the panel container.
517 EXPECT_EQ(kShellWindowId_PanelContainer, child->parent()->id()); 516 EXPECT_EQ(kShellWindowId_PanelContainer, child->parent()->id());
518 DragEnd(); 517 DragEnd();
519 // Child should move, |window| should not. 518 // Child should move, |window| should not.
520 EXPECT_EQ(gfx::Point(20 + 50, 20 + dy).ToString(), 519 EXPECT_EQ(gfx::Point(20 + 50, 20 + dy).ToString(),
521 child->GetBoundsInScreen().origin().ToString()); 520 child->GetBoundsInScreen().origin().ToString());
522 EXPECT_EQ(attached_bounds.ToString(), window->GetBoundsInScreen().ToString()); 521 EXPECT_EQ(attached_bounds.ToString(), window->GetBoundsInScreen().ToString());
523 522
(...skipping 24 matching lines...) Expand all
548 DragMove(20, 0); 547 DragMove(20, 0);
549 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 548 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
550 EXPECT_EQ(kShellWindowId_PanelContainer, child->parent()->id()); 549 EXPECT_EQ(kShellWindowId_PanelContainer, child->parent()->id());
551 DragEnd(); 550 DragEnd();
552 551
553 // When dropped they should return to the default container. 552 // When dropped they should return to the default container.
554 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 553 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
555 EXPECT_EQ(kShellWindowId_DefaultContainer, child->parent()->id()); 554 EXPECT_EQ(kShellWindowId_DefaultContainer, child->parent()->id());
556 } 555 }
557 556
558 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, 557 INSTANTIATE_TEST_CASE_P(LtrRtl,
558 PanelWindowResizerTextDirectionTest,
559 testing::Bool()); 559 testing::Bool());
560 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, 560 INSTANTIATE_TEST_CASE_P(NormalPanelPopup,
561 PanelWindowResizerTransientTest, 561 PanelWindowResizerTransientTest,
562 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, 562 testing::Values(ui::wm::WINDOW_TYPE_NORMAL,
563 ui::wm::WINDOW_TYPE_PANEL, 563 ui::wm::WINDOW_TYPE_PANEL,
564 ui::wm::WINDOW_TYPE_POPUP)); 564 ui::wm::WINDOW_TYPE_POPUP));
565 565
566 } // namespace ash 566 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_window_event_handler.cc ('k') | ash/wm/power_button_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698