| OLD | NEW |
| 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_base.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_util.h" | 11 #include "ash/wm/window_util.h" |
| 12 #include "ash/wm_window.h" | |
| 13 #include "ui/base/hit_test.h" | 12 #include "ui/base/hit_test.h" |
| 14 | 13 |
| 15 namespace ash { | 14 namespace ash { |
| 16 | 15 |
| 17 class MruWindowTrackerTest : public test::AshTestBase { | 16 class MruWindowTrackerTest : public test::AshTestBase { |
| 18 public: | 17 public: |
| 19 MruWindowTrackerTest() {} | 18 MruWindowTrackerTest() {} |
| 20 ~MruWindowTrackerTest() override {} | 19 ~MruWindowTrackerTest() override {} |
| 21 | 20 |
| 22 std::unique_ptr<aura::Window> CreateTestWindow() { | 21 std::unique_ptr<aura::Window> CreateTestWindow() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 | 32 |
| 34 // Basic test that the activation order is tracked. | 33 // Basic test that the activation order is tracked. |
| 35 TEST_F(MruWindowTrackerTest, Basic) { | 34 TEST_F(MruWindowTrackerTest, Basic) { |
| 36 std::unique_ptr<aura::Window> w1(CreateTestWindow()); | 35 std::unique_ptr<aura::Window> w1(CreateTestWindow()); |
| 37 std::unique_ptr<aura::Window> w2(CreateTestWindow()); | 36 std::unique_ptr<aura::Window> w2(CreateTestWindow()); |
| 38 std::unique_ptr<aura::Window> w3(CreateTestWindow()); | 37 std::unique_ptr<aura::Window> w3(CreateTestWindow()); |
| 39 wm::ActivateWindow(w3.get()); | 38 wm::ActivateWindow(w3.get()); |
| 40 wm::ActivateWindow(w2.get()); | 39 wm::ActivateWindow(w2.get()); |
| 41 wm::ActivateWindow(w1.get()); | 40 wm::ActivateWindow(w1.get()); |
| 42 | 41 |
| 43 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList(); | 42 MruWindowTracker::WindowList window_list = |
| 43 mru_window_tracker()->BuildMruWindowList(); |
| 44 ASSERT_EQ(3u, window_list.size()); | 44 ASSERT_EQ(3u, window_list.size()); |
| 45 EXPECT_EQ(w1.get(), window_list[0]->aura_window()); | 45 EXPECT_EQ(w1.get(), window_list[0]); |
| 46 EXPECT_EQ(w2.get(), window_list[1]->aura_window()); | 46 EXPECT_EQ(w2.get(), window_list[1]); |
| 47 EXPECT_EQ(w3.get(), window_list[2]->aura_window()); | 47 EXPECT_EQ(w3.get(), window_list[2]); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Test that minimized windows are not treated specially. | 50 // Test that minimized windows are not treated specially. |
| 51 TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) { | 51 TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) { |
| 52 std::unique_ptr<aura::Window> w1(CreateTestWindow()); | 52 std::unique_ptr<aura::Window> w1(CreateTestWindow()); |
| 53 std::unique_ptr<aura::Window> w2(CreateTestWindow()); | 53 std::unique_ptr<aura::Window> w2(CreateTestWindow()); |
| 54 std::unique_ptr<aura::Window> w3(CreateTestWindow()); | 54 std::unique_ptr<aura::Window> w3(CreateTestWindow()); |
| 55 std::unique_ptr<aura::Window> w4(CreateTestWindow()); | 55 std::unique_ptr<aura::Window> w4(CreateTestWindow()); |
| 56 std::unique_ptr<aura::Window> w5(CreateTestWindow()); | 56 std::unique_ptr<aura::Window> w5(CreateTestWindow()); |
| 57 std::unique_ptr<aura::Window> w6(CreateTestWindow()); | 57 std::unique_ptr<aura::Window> w6(CreateTestWindow()); |
| 58 wm::ActivateWindow(w6.get()); | 58 wm::ActivateWindow(w6.get()); |
| 59 wm::ActivateWindow(w5.get()); | 59 wm::ActivateWindow(w5.get()); |
| 60 wm::ActivateWindow(w4.get()); | 60 wm::ActivateWindow(w4.get()); |
| 61 wm::ActivateWindow(w3.get()); | 61 wm::ActivateWindow(w3.get()); |
| 62 wm::ActivateWindow(w2.get()); | 62 wm::ActivateWindow(w2.get()); |
| 63 wm::ActivateWindow(w1.get()); | 63 wm::ActivateWindow(w1.get()); |
| 64 | 64 |
| 65 wm::GetWindowState(w1.get())->Minimize(); | 65 wm::GetWindowState(w1.get())->Minimize(); |
| 66 wm::GetWindowState(w4.get())->Minimize(); | 66 wm::GetWindowState(w4.get())->Minimize(); |
| 67 wm::GetWindowState(w5.get())->Minimize(); | 67 wm::GetWindowState(w5.get())->Minimize(); |
| 68 | 68 |
| 69 // By minimizing the first window, we activate w2 which will move it to the | 69 // By minimizing the first window, we activate w2 which will move it to the |
| 70 // front of the MRU queue. | 70 // front of the MRU queue. |
| 71 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 71 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 72 | 72 |
| 73 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList(); | 73 MruWindowTracker::WindowList window_list = |
| 74 EXPECT_EQ(w2.get(), window_list[0]->aura_window()); | 74 mru_window_tracker()->BuildMruWindowList(); |
| 75 EXPECT_EQ(w1.get(), window_list[1]->aura_window()); | 75 EXPECT_EQ(w2.get(), window_list[0]); |
| 76 EXPECT_EQ(w3.get(), window_list[2]->aura_window()); | 76 EXPECT_EQ(w1.get(), window_list[1]); |
| 77 EXPECT_EQ(w4.get(), window_list[3]->aura_window()); | 77 EXPECT_EQ(w3.get(), window_list[2]); |
| 78 EXPECT_EQ(w5.get(), window_list[4]->aura_window()); | 78 EXPECT_EQ(w4.get(), window_list[3]); |
| 79 EXPECT_EQ(w6.get(), window_list[5]->aura_window()); | 79 EXPECT_EQ(w5.get(), window_list[4]); |
| 80 EXPECT_EQ(w6.get(), window_list[5]); |
| 80 } | 81 } |
| 81 | 82 |
| 82 // Tests that windows being dragged are only in the WindowList once. | 83 // Tests that windows being dragged are only in the WindowList once. |
| 83 TEST_F(MruWindowTrackerTest, DraggedWindowsInListOnlyOnce) { | 84 TEST_F(MruWindowTrackerTest, DraggedWindowsInListOnlyOnce) { |
| 84 std::unique_ptr<aura::Window> w1(CreateTestWindow()); | 85 std::unique_ptr<aura::Window> w1(CreateTestWindow()); |
| 85 wm::ActivateWindow(w1.get()); | 86 wm::ActivateWindow(w1.get()); |
| 86 | 87 |
| 87 // Start dragging the window. | 88 // Start dragging the window. |
| 88 wm::GetWindowState(w1.get())->CreateDragDetails( | 89 wm::GetWindowState(w1.get())->CreateDragDetails( |
| 89 gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH); | 90 gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH); |
| 90 | 91 |
| 91 // The dragged window should only be in the list once. | 92 // The dragged window should only be in the list once. |
| 92 WmWindow::Windows window_list = | 93 MruWindowTracker::WindowList window_list = |
| 93 mru_window_tracker()->BuildWindowListIgnoreModal(); | 94 mru_window_tracker()->BuildWindowListIgnoreModal(); |
| 94 EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(), | 95 EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(), w1.get())); |
| 95 WmWindow::Get(w1.get()))); | |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace ash | 98 } // namespace ash |
| OLD | NEW |