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

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

Issue 2852493002: chromeos: Converts more tests to AshTestBase (Closed)
Patch Set: Created 3 years, 7 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/system/screen_security/screen_tray_item_unittest.cc ('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/wm/mru_window_tracker.h" 5 #include "ash/wm/mru_window_tracker.h"
6 6
7 #include "ash/public/cpp/shell_window_ids.h" 7 #include "ash/public/cpp/shell_window_ids.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/window_state.h" 10 #include "ash/wm/window_state.h"
11 #include "ash/wm/window_state_aura.h"
12 #include "ash/wm/window_util.h"
11 #include "ash/wm_window.h" 13 #include "ash/wm_window.h"
12 #include "ui/base/hit_test.h" 14 #include "ui/base/hit_test.h"
13 15
14 namespace ash { 16 namespace ash {
15 17
16 class MruWindowTrackerTest : public AshTest { 18 class MruWindowTrackerTest : public test::AshTestBase {
17 public: 19 public:
18 MruWindowTrackerTest() {} 20 MruWindowTrackerTest() {}
19 ~MruWindowTrackerTest() override {} 21 ~MruWindowTrackerTest() override {}
20 22
21 std::unique_ptr<WindowOwner> CreateTestWindow() { 23 std::unique_ptr<aura::Window> CreateTestWindow() {
22 return AshTest::CreateTestWindow(gfx::Rect(0, 0, 400, 400)); 24 return AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
23 } 25 }
24 26
25 MruWindowTracker* mru_window_tracker() { 27 MruWindowTracker* mru_window_tracker() {
26 return Shell::Get()->mru_window_tracker(); 28 return Shell::Get()->mru_window_tracker();
27 } 29 }
28 30
29 private: 31 private:
30 DISALLOW_COPY_AND_ASSIGN(MruWindowTrackerTest); 32 DISALLOW_COPY_AND_ASSIGN(MruWindowTrackerTest);
31 }; 33 };
32 34
33 // Basic test that the activation order is tracked. 35 // Basic test that the activation order is tracked.
34 TEST_F(MruWindowTrackerTest, Basic) { 36 TEST_F(MruWindowTrackerTest, Basic) {
35 std::unique_ptr<WindowOwner> w1_owner(CreateTestWindow()); 37 std::unique_ptr<aura::Window> w1(CreateTestWindow());
36 WmWindow* w1 = w1_owner->window(); 38 std::unique_ptr<aura::Window> w2(CreateTestWindow());
37 std::unique_ptr<WindowOwner> w2_owner(CreateTestWindow()); 39 std::unique_ptr<aura::Window> w3(CreateTestWindow());
38 WmWindow* w2 = w2_owner->window(); 40 wm::ActivateWindow(w3.get());
39 std::unique_ptr<WindowOwner> w3_owner(CreateTestWindow()); 41 wm::ActivateWindow(w2.get());
40 WmWindow* w3 = w3_owner->window(); 42 wm::ActivateWindow(w1.get());
41 w3->Activate();
42 w2->Activate();
43 w1->Activate();
44 43
45 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList(); 44 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList();
46 ASSERT_EQ(3u, window_list.size()); 45 ASSERT_EQ(3u, window_list.size());
47 EXPECT_EQ(w1, window_list[0]); 46 EXPECT_EQ(w1.get(), window_list[0]->aura_window());
48 EXPECT_EQ(w2, window_list[1]); 47 EXPECT_EQ(w2.get(), window_list[1]->aura_window());
49 EXPECT_EQ(w3, window_list[2]); 48 EXPECT_EQ(w3.get(), window_list[2]->aura_window());
50 } 49 }
51 50
52 // Test that minimized windows are not treated specially. 51 // Test that minimized windows are not treated specially.
53 TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) { 52 TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) {
54 std::unique_ptr<WindowOwner> w1_owner(CreateTestWindow()); 53 std::unique_ptr<aura::Window> w1(CreateTestWindow());
55 WmWindow* w1 = w1_owner->window(); 54 std::unique_ptr<aura::Window> w2(CreateTestWindow());
56 std::unique_ptr<WindowOwner> w2_owner(CreateTestWindow()); 55 std::unique_ptr<aura::Window> w3(CreateTestWindow());
57 WmWindow* w2 = w2_owner->window(); 56 std::unique_ptr<aura::Window> w4(CreateTestWindow());
58 std::unique_ptr<WindowOwner> w3_owner(CreateTestWindow()); 57 std::unique_ptr<aura::Window> w5(CreateTestWindow());
59 WmWindow* w3 = w3_owner->window(); 58 std::unique_ptr<aura::Window> w6(CreateTestWindow());
60 std::unique_ptr<WindowOwner> w4_owner(CreateTestWindow()); 59 wm::ActivateWindow(w6.get());
61 WmWindow* w4 = w4_owner->window(); 60 wm::ActivateWindow(w5.get());
62 std::unique_ptr<WindowOwner> w5_owner(CreateTestWindow()); 61 wm::ActivateWindow(w4.get());
63 WmWindow* w5 = w5_owner->window(); 62 wm::ActivateWindow(w3.get());
64 std::unique_ptr<WindowOwner> w6_owner(CreateTestWindow()); 63 wm::ActivateWindow(w2.get());
65 WmWindow* w6 = w6_owner->window(); 64 wm::ActivateWindow(w1.get());
66 w6->Activate();
67 w5->Activate();
68 w4->Activate();
69 w3->Activate();
70 w2->Activate();
71 w1->Activate();
72 65
73 w1->GetWindowState()->Minimize(); 66 wm::GetWindowState(w1.get())->Minimize();
74 w4->GetWindowState()->Minimize(); 67 wm::GetWindowState(w4.get())->Minimize();
75 w5->GetWindowState()->Minimize(); 68 wm::GetWindowState(w5.get())->Minimize();
76 69
77 // By minimizing the first window, we activate w2 which will move it to the 70 // By minimizing the first window, we activate w2 which will move it to the
78 // front of the MRU queue. 71 // front of the MRU queue.
79 EXPECT_TRUE(w2->IsActive()); 72 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
80 73
81 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList(); 74 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList();
82 EXPECT_EQ(w2, window_list[0]); 75 EXPECT_EQ(w2.get(), window_list[0]->aura_window());
83 EXPECT_EQ(w1, window_list[1]); 76 EXPECT_EQ(w1.get(), window_list[1]->aura_window());
84 EXPECT_EQ(w3, window_list[2]); 77 EXPECT_EQ(w3.get(), window_list[2]->aura_window());
85 EXPECT_EQ(w4, window_list[3]); 78 EXPECT_EQ(w4.get(), window_list[3]->aura_window());
86 EXPECT_EQ(w5, window_list[4]); 79 EXPECT_EQ(w5.get(), window_list[4]->aura_window());
87 EXPECT_EQ(w6, window_list[5]); 80 EXPECT_EQ(w6.get(), window_list[5]->aura_window());
88 } 81 }
89 82
90 // Tests that windows being dragged are only in the WindowList once. 83 // Tests that windows being dragged are only in the WindowList once.
91 TEST_F(MruWindowTrackerTest, DraggedWindowsInListOnlyOnce) { 84 TEST_F(MruWindowTrackerTest, DraggedWindowsInListOnlyOnce) {
92 std::unique_ptr<WindowOwner> w1_owner(CreateTestWindow()); 85 std::unique_ptr<aura::Window> w1(CreateTestWindow());
93 WmWindow* w1 = w1_owner->window(); 86 wm::ActivateWindow(w1.get());
94 w1->Activate();
95 87
96 // Start dragging the window. 88 // Start dragging the window.
97 w1->GetWindowState()->CreateDragDetails( 89 wm::GetWindowState(w1.get())->CreateDragDetails(
98 gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH); 90 gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH);
99 91
100 // The dragged window should only be in the list once. 92 // The dragged window should only be in the list once.
101 WmWindow::Windows window_list = 93 WmWindow::Windows window_list =
102 mru_window_tracker()->BuildWindowListIgnoreModal(); 94 mru_window_tracker()->BuildWindowListIgnoreModal();
103 EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(), w1)); 95 EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(),
96 WmWindow::Get(w1.get())));
104 } 97 }
105 98
106 } // namespace ash 99 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/screen_security/screen_tray_item_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698