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

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

Issue 657583003: Chrome OS: Ash support for >=3 displays. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again to resolve conflicts at TOT Created 6 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
« no previous file with comments | « ash/wm/drag_window_resizer.cc ('k') | ui/display/chromeos/display_configurator.cc » ('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) 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/drag_window_resizer.h" 5 #include "ash/wm/drag_window_resizer.h"
6 6
7 #include "ash/display/mouse_cursor_event_filter.h" 7 #include "ash/display/mouse_cursor_event_filter.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 350 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
351 Shell::GetScreen()->GetPrimaryDisplay()); 351 Shell::GetScreen()->GetPrimaryDisplay());
352 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 352 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
353 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 353 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
354 { 354 {
355 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 355 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
356 window_.get(), gfx::Point(), HTCAPTION)); 356 window_.get(), gfx::Point(), HTCAPTION));
357 ASSERT_TRUE(resizer.get()); 357 ASSERT_TRUE(resizer.get());
358 DragWindowResizer* drag_resizer = DragWindowResizer::instance_; 358 DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
359 ASSERT_TRUE(drag_resizer); 359 ASSERT_TRUE(drag_resizer);
360 EXPECT_FALSE(drag_resizer->drag_window_controller_.get()); 360 EXPECT_EQ(0u, drag_resizer->drag_window_controllers_.size());
361 361
362 // The pointer is inside the primary root. The drag window controller 362 // The pointer is inside the primary root. The drag window controller
363 // should be NULL. 363 // should be NULL.
364 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); 364 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0);
365 EXPECT_FALSE(drag_resizer->drag_window_controller_.get()); 365 EXPECT_EQ(0u, drag_resizer->drag_window_controllers_.size());
366 366
367 // The window spans both root windows. 367 // The window spans both root windows.
368 resizer->Drag(CalculateDragPoint(*resizer, 798, 10), 0); 368 resizer->Drag(CalculateDragPoint(*resizer, 798, 10), 0);
369 EXPECT_EQ(1u, drag_resizer->drag_window_controllers_.size());
369 DragWindowController* controller = 370 DragWindowController* controller =
370 drag_resizer->drag_window_controller_.get(); 371 drag_resizer->drag_window_controllers_[0];
371 ASSERT_TRUE(controller); 372 ASSERT_TRUE(controller);
372 373
373 ASSERT_TRUE(controller->drag_widget_); 374 ASSERT_TRUE(controller->drag_widget_);
374 ui::Layer* drag_layer = 375 ui::Layer* drag_layer =
375 controller->drag_widget_->GetNativeWindow()->layer(); 376 controller->drag_widget_->GetNativeWindow()->layer();
376 ASSERT_TRUE(drag_layer); 377 ASSERT_TRUE(drag_layer);
377 // Check if |resizer->layer_| is properly set to the drag widget. 378 // Check if |resizer->layer_| is properly set to the drag widget.
378 const std::vector<ui::Layer*>& layers = drag_layer->children(); 379 const std::vector<ui::Layer*>& layers = drag_layer->children();
379 EXPECT_FALSE(layers.empty()); 380 EXPECT_FALSE(layers.empty());
380 EXPECT_EQ(controller->layer_owner_->root(), layers.back()); 381 EXPECT_EQ(controller->layer_owner_->root(), layers.back());
381 382
382 // |window_| should be opaque since the pointer is still on the primary 383 // |window_| should be opaque since the pointer is still on the primary
383 // root window. The drag window should be semi-transparent. 384 // root window. The drag window should be semi-transparent.
384 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 385 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
385 ASSERT_TRUE(controller->drag_widget_); 386 ASSERT_TRUE(controller->drag_widget_);
386 EXPECT_GT(1.0f, drag_layer->opacity()); 387 EXPECT_GT(1.0f, drag_layer->opacity());
387 388
388 // Enter the pointer to the secondary display. 389 // Enter the pointer to the secondary display.
389 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 390 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
390 controller = drag_resizer->drag_window_controller_.get(); 391 EXPECT_EQ(1u, drag_resizer->drag_window_controllers_.size());
392 controller = drag_resizer->drag_window_controllers_[0];
391 ASSERT_TRUE(controller); 393 ASSERT_TRUE(controller);
392 // |window_| should be transparent, and the drag window should be opaque. 394 // |window_| should be transparent, and the drag window should be opaque.
393 EXPECT_GT(1.0f, window_->layer()->opacity()); 395 EXPECT_GT(1.0f, window_->layer()->opacity());
394 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity()); 396 EXPECT_FLOAT_EQ(1.0f, drag_layer->opacity());
395 397
396 resizer->CompleteDrag(); 398 resizer->CompleteDrag();
397 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 399 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
398 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 400 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
399 } 401 }
400 402
401 // Do the same test with RevertDrag(). 403 // Do the same test with RevertDrag().
402 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 404 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
403 Shell::GetScreen()->GetPrimaryDisplay()); 405 Shell::GetScreen()->GetPrimaryDisplay());
404 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 406 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
405 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 407 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
406 { 408 {
407 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 409 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer(
408 window_.get(), gfx::Point(), HTCAPTION)); 410 window_.get(), gfx::Point(), HTCAPTION));
409 ASSERT_TRUE(resizer.get()); 411 ASSERT_TRUE(resizer.get());
410 DragWindowResizer* drag_resizer = DragWindowResizer::instance_; 412 DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
411 ASSERT_TRUE(drag_resizer); 413 ASSERT_TRUE(drag_resizer);
412 EXPECT_FALSE(drag_resizer->drag_window_controller_.get()); 414 EXPECT_EQ(0u, drag_resizer->drag_window_controllers_.size());
413 415
414 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); 416 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0);
415 resizer->RevertDrag(); 417 resizer->RevertDrag();
416 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 418 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
417 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 419 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
418 } 420 }
419 } 421 }
420 422
421 // Verifies if the resizer sets and resets 423 // Verifies if the resizer sets and resets
422 // MouseCursorEventFilter::mouse_warp_mode_ as expected. 424 // MouseCursorEventFilter::mouse_warp_mode_ as expected.
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 window, gfx::Point(), HTCAPTION)); 628 window, gfx::Point(), HTCAPTION));
627 ASSERT_TRUE(resizer.get()); 629 ASSERT_TRUE(resizer.get());
628 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 630 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
629 EXPECT_TRUE(WarpMouseCursorIfNecessary(root_windows[0], 631 EXPECT_TRUE(WarpMouseCursorIfNecessary(root_windows[0],
630 gfx::Point(399, 200))); 632 gfx::Point(399, 200)));
631 resizer->CompleteDrag(); 633 resizer->CompleteDrag();
632 } 634 }
633 } 635 }
634 636
635 } // namespace ash 637 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/drag_window_resizer.cc ('k') | ui/display/chromeos/display_configurator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698