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

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

Issue 2046633006: MruWindowTrackerTest for mash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CreateTestWindow 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/mus/BUILD.gn ('k') | no next file » | 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/common/wm/mru_window_tracker.h" 5 #include "ash/common/wm/mru_window_tracker.h"
6 6
7 #include "ash/common/shell_window_ids.h" 7 #include "ash/common/shell_window_ids.h"
8 #include "ash/common/wm/window_state.h" 8 #include "ash/common/wm/window_state.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/mus/bridge/wm_window_mus.h" 10 #include "ash/mus/bridge/wm_window_mus.h"
11 #include "ash/mus/test/wm_test_base.h" 11 #include "ash/mus/test/wm_test_base.h"
12 #include "ui/base/hit_test.h" 12 #include "ui/base/hit_test.h"
13 13
14 namespace ash { 14 namespace ash {
15 15
16 class MruWindowTrackerTest : public test::AshTestBase { 16 class MruWindowTrackerTest : public mus::WmTestBase {
17 public: 17 public:
18 MruWindowTrackerTest() {} 18 MruWindowTrackerTest() {}
19 ~MruWindowTrackerTest() override {} 19 ~MruWindowTrackerTest() override {}
20 20
21 aura::Window* CreateWindow() { 21 WmWindow* CreateTestWindow() {
22 return CreateTestWindowInShellWithBounds(gfx::Rect(0, 0, 400, 400)); 22 return mus::WmWindowMus::Get(
23 mus::WmTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400)));
23 } 24 }
24 25
25 ash::MruWindowTracker* mru_window_tracker() { 26 MruWindowTracker* mru_window_tracker() {
26 return Shell::GetInstance()->mru_window_tracker(); 27 return WmShell::Get()->GetMruWindowTracker();
27 } 28 }
28 29
29 private: 30 private:
30 DISALLOW_COPY_AND_ASSIGN(MruWindowTrackerTest); 31 DISALLOW_COPY_AND_ASSIGN(MruWindowTrackerTest);
31 }; 32 };
32 33
33 // Basic test that the activation order is tracked. 34 // Basic test that the activation order is tracked.
34 TEST_F(MruWindowTrackerTest, Basic) { 35 TEST_F(MruWindowTrackerTest, Basic) {
35 std::unique_ptr<aura::Window> w1(CreateWindow()); 36 WmWindow* w1 = CreateTestWindow();
36 std::unique_ptr<aura::Window> w2(CreateWindow()); 37 WmWindow* w2 = CreateTestWindow();
37 std::unique_ptr<aura::Window> w3(CreateWindow()); 38 WmWindow* w3 = CreateTestWindow();
38 wm::ActivateWindow(w3.get()); 39 w3->Activate();
39 wm::ActivateWindow(w2.get()); 40 w2->Activate();
40 wm::ActivateWindow(w1.get()); 41 w1->Activate();
41 42
42 aura::Window::Windows window_list = 43 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList();
43 WmWindowAura::ToAuraWindows(mru_window_tracker()->BuildMruWindowList()); 44 EXPECT_EQ(w1, window_list[0]);
44 EXPECT_EQ(w1.get(), window_list[0]); 45 EXPECT_EQ(w2, window_list[1]);
45 EXPECT_EQ(w2.get(), window_list[1]); 46 EXPECT_EQ(w3, window_list[2]);
46 EXPECT_EQ(w3.get(), window_list[2]);
47 } 47 }
48 48
49 // Test that minimized windows are considered least recently used (but kept in 49 // Test that minimized windows are considered least recently used (but kept in
50 // correct relative order). 50 // correct relative order).
51 TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) { 51 TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) {
52 std::unique_ptr<aura::Window> w1(CreateWindow()); 52 WmWindow* w1 = CreateTestWindow();
53 std::unique_ptr<aura::Window> w2(CreateWindow()); 53 WmWindow* w2 = CreateTestWindow();
54 std::unique_ptr<aura::Window> w3(CreateWindow()); 54 WmWindow* w3 = CreateTestWindow();
55 std::unique_ptr<aura::Window> w4(CreateWindow()); 55 WmWindow* w4 = CreateTestWindow();
56 std::unique_ptr<aura::Window> w5(CreateWindow()); 56 WmWindow* w5 = CreateTestWindow();
57 std::unique_ptr<aura::Window> w6(CreateWindow()); 57 WmWindow* w6 = CreateTestWindow();
58 wm::ActivateWindow(w6.get()); 58 w6->Activate();
59 wm::ActivateWindow(w5.get()); 59 w5->Activate();
60 wm::ActivateWindow(w4.get()); 60 w4->Activate();
61 wm::ActivateWindow(w3.get()); 61 w3->Activate();
62 wm::ActivateWindow(w2.get()); 62 w2->Activate();
63 wm::ActivateWindow(w1.get()); 63 w1->Activate();
64 64
65 wm::GetWindowState(w1.get())->Minimize(); 65 w1->GetWindowState()->Minimize();
66 wm::GetWindowState(w4.get())->Minimize(); 66 w4->GetWindowState()->Minimize();
67 wm::GetWindowState(w5.get())->Minimize(); 67 w5->GetWindowState()->Minimize();
68 68
69 // Expect the relative order of minimized windows to remain the same, but all 69 // Expect the relative order of minimized windows to remain the same, but all
70 // minimized windows to be at the end of the list. 70 // minimized windows to be at the end of the list.
71 aura::Window::Windows window_list = 71 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList();
72 WmWindowAura::ToAuraWindows(mru_window_tracker()->BuildMruWindowList()); 72 EXPECT_EQ(w2, window_list[0]);
73 EXPECT_EQ(w2.get(), window_list[0]); 73 EXPECT_EQ(w3, window_list[1]);
74 EXPECT_EQ(w3.get(), window_list[1]); 74 EXPECT_EQ(w6, window_list[2]);
75 EXPECT_EQ(w6.get(), window_list[2]); 75 EXPECT_EQ(w1, window_list[3]);
76 EXPECT_EQ(w1.get(), window_list[3]); 76 EXPECT_EQ(w4, window_list[4]);
77 EXPECT_EQ(w4.get(), window_list[4]); 77 EXPECT_EQ(w5, window_list[5]);
78 EXPECT_EQ(w5.get(), window_list[5]);
79 } 78 }
80 79
81 // Tests that windows being dragged are only in the WindowList once. 80 // Tests that windows being dragged are only in the WindowList once.
82 TEST_F(MruWindowTrackerTest, DraggedWindowsInListOnlyOnce) { 81 // Disabled, see http://crbug.com/618058.
83 std::unique_ptr<aura::Window> w1(CreateWindow()); 82 TEST_F(MruWindowTrackerTest, DISABLED_DraggedWindowsInListOnlyOnce) {
84 wm::ActivateWindow(w1.get()); 83 WmWindow* w1 = CreateTestWindow();
84 w1->Activate();
85 85
86 // Start dragging the window. 86 // Start dragging the window.
87 wm::GetWindowState(w1.get())->CreateDragDetails( 87 w1->GetWindowState()->CreateDragDetails(
88 gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH); 88 gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH);
89 89
90 // During a drag the window is reparented by the Docked container. 90 // During a drag the window is reparented by the Docked container.
91 aura::Window* drag_container = Shell::GetContainer( 91 WmWindow* drag_container = w1->GetRootWindow()->GetChildByShellWindowId(
92 Shell::GetTargetRootWindow(), kShellWindowId_DockedContainer); 92 kShellWindowId_DockedContainer);
93 drag_container->AddChild(w1.get()); 93 drag_container->AddChild(w1);
94 EXPECT_TRUE(wm::GetWindowState(w1.get())->is_dragged()); 94 EXPECT_TRUE(w1->GetWindowState()->is_dragged());
95 95
96 // The dragged window should only be in the list once. 96 // The dragged window should only be in the list once.
97 aura::Window::Windows window_list = WmWindowAura::ToAuraWindows( 97 WmWindow::Windows window_list =
98 mru_window_tracker()->BuildWindowListIgnoreModal()); 98 mru_window_tracker()->BuildWindowListIgnoreModal();
99 EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(), w1.get())); 99 EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(), w1));
100 } 100 }
101 101
102 } // namespace ash 102 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698