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

Side by Side Diff: ash/display/screen_position_controller_unittest.cc

Issue 1867223004: Convert //ash from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/display/screen_position_controller.h" 5 #include "ash/display/screen_position_controller.h"
6 6
oshima 2016/04/08 07:09:40 include?
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/screen_util.h" 8 #include "ash/screen_util.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
11 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
12 #include "ash/test/shell_test_api.h" 12 #include "ash/test/shell_test_api.h"
13 #include "ui/aura/env.h" 13 #include "ui/aura/env.h"
14 #include "ui/aura/test/test_window_delegate.h" 14 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/aura/window_tracker.h" 15 #include "ui/aura/window_tracker.h"
16 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
(...skipping 19 matching lines...) Expand all
36 #define MAYBE_ConvertToScreenWhileRemovingSecondaryDisplay \ 36 #define MAYBE_ConvertToScreenWhileRemovingSecondaryDisplay \
37 ConvertToScreenWhileRemovingSecondaryDisplay 37 ConvertToScreenWhileRemovingSecondaryDisplay
38 #endif 38 #endif
39 39
40 namespace ash { 40 namespace ash {
41 namespace test { 41 namespace test {
42 42
43 namespace { 43 namespace {
44 44
45 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) { 45 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) {
46 scoped_ptr<display::DisplayLayout> layout(Shell::GetInstance() 46 std::unique_ptr<display::DisplayLayout> layout(Shell::GetInstance()
47 ->display_manager() 47 ->display_manager()
48 ->GetCurrentDisplayLayout() 48 ->GetCurrentDisplayLayout()
49 .Copy()); 49 .Copy());
50 layout->placement_list[0].position = position; 50 layout->placement_list[0].position = position;
51 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 51 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
52 std::move(layout)); 52 std::move(layout));
53 } 53 }
54 54
55 ScreenPositionController* GetScreenPositionController() { 55 ScreenPositionController* GetScreenPositionController() {
56 ShellTestApi test_api(Shell::GetInstance()); 56 ShellTestApi test_api(Shell::GetInstance());
57 return test_api.screen_position_controller(); 57 return test_api.screen_position_controller();
58 } 58 }
59 59
(...skipping 19 matching lines...) Expand all
79 // Converts a point (x, y) in host window's coordinate to screen and 79 // Converts a point (x, y) in host window's coordinate to screen and
80 // returns its string representation. 80 // returns its string representation.
81 std::string ConvertHostPointToScreen(int x, int y) const { 81 std::string ConvertHostPointToScreen(int x, int y) const {
82 gfx::Point point(x, y); 82 gfx::Point point(x, y);
83 GetScreenPositionController()->ConvertHostPointToScreen( 83 GetScreenPositionController()->ConvertHostPointToScreen(
84 window_->GetRootWindow(), &point); 84 window_->GetRootWindow(), &point);
85 return point.ToString(); 85 return point.ToString();
86 } 86 }
87 87
88 protected: 88 protected:
89 scoped_ptr<aura::Window> window_; 89 std::unique_ptr<aura::Window> window_;
90 aura::test::TestWindowDelegate window_delegate_; 90 aura::test::TestWindowDelegate window_delegate_;
91 91
92 private: 92 private:
93 DISALLOW_COPY_AND_ASSIGN(ScreenPositionControllerTest); 93 DISALLOW_COPY_AND_ASSIGN(ScreenPositionControllerTest);
94 }; 94 };
95 95
96 } // namespace 96 } // namespace
97 97
98 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreen) { 98 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreen) {
99 // Make sure that the point is in host coordinates. (crbug.com/521919) 99 // Make sure that the point is in host coordinates. (crbug.com/521919)
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // We want to check that none of these synthetic events are dispatched after 334 // We want to check that none of these synthetic events are dispatched after
335 // ScreenPositionClient has been detached from the root window. 335 // ScreenPositionClient has been detached from the root window.
336 GetEventGenerator().MoveMouseTo(800, 200); 336 GetEventGenerator().MoveMouseTo(800, 200);
337 EXPECT_TRUE(window_->GetBoundsInScreen().Contains( 337 EXPECT_TRUE(window_->GetBoundsInScreen().Contains(
338 aura::Env::GetInstance()->last_mouse_location())); 338 aura::Env::GetInstance()->last_mouse_location()));
339 339
340 aura::Window::Windows root_windows = 340 aura::Window::Windows root_windows =
341 Shell::GetInstance()->GetAllRootWindows(); 341 Shell::GetInstance()->GetAllRootWindows();
342 aura::WindowTracker tracker; 342 aura::WindowTracker tracker;
343 tracker.Add(root_windows[1]); 343 tracker.Add(root_windows[1]);
344 scoped_ptr<ConvertToScreenEventHandler> event_handler( 344 std::unique_ptr<ConvertToScreenEventHandler> event_handler(
345 new ConvertToScreenEventHandler); 345 new ConvertToScreenEventHandler);
346 346
347 // Remove the secondary monitor. 347 // Remove the secondary monitor.
348 UpdateDisplay("600x600"); 348 UpdateDisplay("600x600");
349 349
350 // The secondary root window is not immediately destroyed. 350 // The secondary root window is not immediately destroyed.
351 EXPECT_TRUE(tracker.Contains(root_windows[1])); 351 EXPECT_TRUE(tracker.Contains(root_windows[1]));
352 352
353 RunAllPendingInMessageLoop(); 353 RunAllPendingInMessageLoop();
354 354
355 // Check that we waited long enough and that the secondary root window was 355 // Check that we waited long enough and that the secondary root window was
356 // destroyed. 356 // destroyed.
357 EXPECT_FALSE(tracker.Contains(root_windows[1])); 357 EXPECT_FALSE(tracker.Contains(root_windows[1]));
358 358
359 // Check that we could convert all of the mouse events we got to screen 359 // Check that we could convert all of the mouse events we got to screen
360 // coordinates. 360 // coordinates.
361 EXPECT_TRUE(event_handler->could_convert_to_screen()); 361 EXPECT_TRUE(event_handler->could_convert_to_screen());
362 } 362 }
363 363
364 } // namespace test 364 } // namespace test
365 } // namespace ash 365 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698