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

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

Issue 2042913002: Converts MruWindowTracker to work with common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: not equal 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/mru_window_tracker.cc ('k') | ash/wm/panels/panel_layout_manager_unittest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/wm/mru_window_tracker.h"
6
7 #include "ash/aura/wm_window_aura.h"
5 #include "ash/common/shell_window_ids.h" 8 #include "ash/common/shell_window_ids.h"
6 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
7 #include "ash/shell.h" 10 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
9 #include "ash/test/test_shelf_delegate.h"
10 #include "ash/wm/mru_window_tracker.h"
11 #include "ash/wm/window_state_aura.h" 12 #include "ash/wm/window_state_aura.h"
12 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
13 #include "base/compiler_specific.h"
14 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
16 #include "ui/base/hit_test.h" 15 #include "ui/base/hit_test.h"
17 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
18 17
19 namespace ash { 18 namespace ash {
20 19
21 class MruWindowTrackerTest : public test::AshTestBase { 20 class MruWindowTrackerTest : public test::AshTestBase {
22 public: 21 public:
23 MruWindowTrackerTest() {} 22 MruWindowTrackerTest() {}
24 ~MruWindowTrackerTest() override {} 23 ~MruWindowTrackerTest() override {}
(...skipping 12 matching lines...) Expand all
37 36
38 // Basic test that the activation order is tracked. 37 // Basic test that the activation order is tracked.
39 TEST_F(MruWindowTrackerTest, Basic) { 38 TEST_F(MruWindowTrackerTest, Basic) {
40 std::unique_ptr<aura::Window> w1(CreateWindow()); 39 std::unique_ptr<aura::Window> w1(CreateWindow());
41 std::unique_ptr<aura::Window> w2(CreateWindow()); 40 std::unique_ptr<aura::Window> w2(CreateWindow());
42 std::unique_ptr<aura::Window> w3(CreateWindow()); 41 std::unique_ptr<aura::Window> w3(CreateWindow());
43 wm::ActivateWindow(w3.get()); 42 wm::ActivateWindow(w3.get());
44 wm::ActivateWindow(w2.get()); 43 wm::ActivateWindow(w2.get());
45 wm::ActivateWindow(w1.get()); 44 wm::ActivateWindow(w1.get());
46 45
47 MruWindowTracker::WindowList window_list = 46 aura::Window::Windows window_list =
48 mru_window_tracker()->BuildMruWindowList(); 47 WmWindowAura::ToAuraWindows(mru_window_tracker()->BuildMruWindowList());
49 EXPECT_EQ(w1.get(), window_list[0]); 48 EXPECT_EQ(w1.get(), window_list[0]);
50 EXPECT_EQ(w2.get(), window_list[1]); 49 EXPECT_EQ(w2.get(), window_list[1]);
51 EXPECT_EQ(w3.get(), window_list[2]); 50 EXPECT_EQ(w3.get(), window_list[2]);
52 } 51 }
53 52
54 // Test that minimized windows are considered least recently used (but kept in 53 // Test that minimized windows are considered least recently used (but kept in
55 // correct relative order). 54 // correct relative order).
56 TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) { 55 TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) {
57 std::unique_ptr<aura::Window> w1(CreateWindow()); 56 std::unique_ptr<aura::Window> w1(CreateWindow());
58 std::unique_ptr<aura::Window> w2(CreateWindow()); 57 std::unique_ptr<aura::Window> w2(CreateWindow());
59 std::unique_ptr<aura::Window> w3(CreateWindow()); 58 std::unique_ptr<aura::Window> w3(CreateWindow());
60 std::unique_ptr<aura::Window> w4(CreateWindow()); 59 std::unique_ptr<aura::Window> w4(CreateWindow());
61 std::unique_ptr<aura::Window> w5(CreateWindow()); 60 std::unique_ptr<aura::Window> w5(CreateWindow());
62 std::unique_ptr<aura::Window> w6(CreateWindow()); 61 std::unique_ptr<aura::Window> w6(CreateWindow());
63 wm::ActivateWindow(w6.get()); 62 wm::ActivateWindow(w6.get());
64 wm::ActivateWindow(w5.get()); 63 wm::ActivateWindow(w5.get());
65 wm::ActivateWindow(w4.get()); 64 wm::ActivateWindow(w4.get());
66 wm::ActivateWindow(w3.get()); 65 wm::ActivateWindow(w3.get());
67 wm::ActivateWindow(w2.get()); 66 wm::ActivateWindow(w2.get());
68 wm::ActivateWindow(w1.get()); 67 wm::ActivateWindow(w1.get());
69 68
70 wm::GetWindowState(w1.get())->Minimize(); 69 wm::GetWindowState(w1.get())->Minimize();
71 wm::GetWindowState(w4.get())->Minimize(); 70 wm::GetWindowState(w4.get())->Minimize();
72 wm::GetWindowState(w5.get())->Minimize(); 71 wm::GetWindowState(w5.get())->Minimize();
73 72
74 // Expect the relative order of minimized windows to remain the same, but all 73 // Expect the relative order of minimized windows to remain the same, but all
75 // minimized windows to be at the end of the list. 74 // minimized windows to be at the end of the list.
76 MruWindowTracker::WindowList window_list = 75 aura::Window::Windows window_list =
77 mru_window_tracker()->BuildMruWindowList(); 76 WmWindowAura::ToAuraWindows(mru_window_tracker()->BuildMruWindowList());
78 EXPECT_EQ(w2.get(), window_list[0]); 77 EXPECT_EQ(w2.get(), window_list[0]);
79 EXPECT_EQ(w3.get(), window_list[1]); 78 EXPECT_EQ(w3.get(), window_list[1]);
80 EXPECT_EQ(w6.get(), window_list[2]); 79 EXPECT_EQ(w6.get(), window_list[2]);
81 EXPECT_EQ(w1.get(), window_list[3]); 80 EXPECT_EQ(w1.get(), window_list[3]);
82 EXPECT_EQ(w4.get(), window_list[4]); 81 EXPECT_EQ(w4.get(), window_list[4]);
83 EXPECT_EQ(w5.get(), window_list[5]); 82 EXPECT_EQ(w5.get(), window_list[5]);
84 } 83 }
85 84
86 // Tests that windows being dragged are only in the WindowList once. 85 // Tests that windows being dragged are only in the WindowList once.
87 TEST_F(MruWindowTrackerTest, DraggedWindowsInListOnlyOnce) { 86 TEST_F(MruWindowTrackerTest, DraggedWindowsInListOnlyOnce) {
88 std::unique_ptr<aura::Window> w1(CreateWindow()); 87 std::unique_ptr<aura::Window> w1(CreateWindow());
89 wm::ActivateWindow(w1.get()); 88 wm::ActivateWindow(w1.get());
90 89
91 // Start dragging the window. 90 // Start dragging the window.
92 wm::GetWindowState(w1.get())->CreateDragDetails( 91 wm::GetWindowState(w1.get())->CreateDragDetails(
93 gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH); 92 gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH);
94 93
95 // During a drag the window is reparented by the Docked container. 94 // During a drag the window is reparented by the Docked container.
96 aura::Window* drag_container = Shell::GetContainer( 95 aura::Window* drag_container = Shell::GetContainer(
97 Shell::GetTargetRootWindow(), kShellWindowId_DockedContainer); 96 Shell::GetTargetRootWindow(), kShellWindowId_DockedContainer);
98 drag_container->AddChild(w1.get()); 97 drag_container->AddChild(w1.get());
99 EXPECT_TRUE(wm::GetWindowState(w1.get())->is_dragged()); 98 EXPECT_TRUE(wm::GetWindowState(w1.get())->is_dragged());
100 99
101 // The dragged window should only be in the list once. 100 // The dragged window should only be in the list once.
102 MruWindowTracker::WindowList window_list = 101 aura::Window::Windows window_list = WmWindowAura::ToAuraWindows(
103 mru_window_tracker()->BuildWindowListIgnoreModal(); 102 mru_window_tracker()->BuildWindowListIgnoreModal());
104 EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(), w1.get())); 103 EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(), w1.get()));
105 } 104 }
106 105
107 } // namespace ash 106 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/mru_window_tracker.cc ('k') | ash/wm/panels/panel_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698