| 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/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" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 w3->Activate(); | 39 w3->Activate(); |
| 40 w2->Activate(); | 40 w2->Activate(); |
| 41 w1->Activate(); | 41 w1->Activate(); |
| 42 | 42 |
| 43 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList(); | 43 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList(); |
| 44 EXPECT_EQ(w1, window_list[0]); | 44 EXPECT_EQ(w1, window_list[0]); |
| 45 EXPECT_EQ(w2, window_list[1]); | 45 EXPECT_EQ(w2, window_list[1]); |
| 46 EXPECT_EQ(w3, window_list[2]); | 46 EXPECT_EQ(w3, 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 not treated specially. |
| 50 // correct relative order). | |
| 51 TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) { | 50 TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) { |
| 52 WmWindow* w1 = CreateTestWindow(); | 51 WmWindow* w1 = CreateTestWindow(); |
| 53 WmWindow* w2 = CreateTestWindow(); | 52 WmWindow* w2 = CreateTestWindow(); |
| 54 WmWindow* w3 = CreateTestWindow(); | 53 WmWindow* w3 = CreateTestWindow(); |
| 55 WmWindow* w4 = CreateTestWindow(); | 54 WmWindow* w4 = CreateTestWindow(); |
| 56 WmWindow* w5 = CreateTestWindow(); | 55 WmWindow* w5 = CreateTestWindow(); |
| 57 WmWindow* w6 = CreateTestWindow(); | 56 WmWindow* w6 = CreateTestWindow(); |
| 58 w6->Activate(); | 57 w6->Activate(); |
| 59 w5->Activate(); | 58 w5->Activate(); |
| 60 w4->Activate(); | 59 w4->Activate(); |
| 61 w3->Activate(); | 60 w3->Activate(); |
| 62 w2->Activate(); | 61 w2->Activate(); |
| 63 w1->Activate(); | 62 w1->Activate(); |
| 64 | 63 |
| 65 w1->GetWindowState()->Minimize(); | 64 w1->GetWindowState()->Minimize(); |
| 66 w4->GetWindowState()->Minimize(); | 65 w4->GetWindowState()->Minimize(); |
| 67 w5->GetWindowState()->Minimize(); | 66 w5->GetWindowState()->Minimize(); |
| 68 | 67 |
| 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. | |
| 71 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList(); | 68 WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList(); |
| 72 EXPECT_EQ(w2, window_list[0]); | 69 EXPECT_EQ(w1, window_list[0]); |
| 73 EXPECT_EQ(w3, window_list[1]); | 70 EXPECT_EQ(w2, window_list[1]); |
| 74 EXPECT_EQ(w6, window_list[2]); | 71 EXPECT_EQ(w3, window_list[2]); |
| 75 EXPECT_EQ(w1, window_list[3]); | 72 EXPECT_EQ(w4, window_list[3]); |
| 76 EXPECT_EQ(w4, window_list[4]); | 73 EXPECT_EQ(w5, window_list[4]); |
| 77 EXPECT_EQ(w5, window_list[5]); | 74 EXPECT_EQ(w6, window_list[5]); |
| 78 } | 75 } |
| 79 | 76 |
| 80 // Tests that windows being dragged are only in the WindowList once. | 77 // Tests that windows being dragged are only in the WindowList once. |
| 81 // Disabled, see http://crbug.com/618058. | 78 // Disabled, see http://crbug.com/618058. |
| 82 TEST_F(MruWindowTrackerTest, DISABLED_DraggedWindowsInListOnlyOnce) { | 79 TEST_F(MruWindowTrackerTest, DISABLED_DraggedWindowsInListOnlyOnce) { |
| 83 WmWindow* w1 = CreateTestWindow(); | 80 WmWindow* w1 = CreateTestWindow(); |
| 84 w1->Activate(); | 81 w1->Activate(); |
| 85 | 82 |
| 86 // Start dragging the window. | 83 // Start dragging the window. |
| 87 w1->GetWindowState()->CreateDragDetails( | 84 w1->GetWindowState()->CreateDragDetails( |
| 88 gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH); | 85 gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH); |
| 89 | 86 |
| 90 // During a drag the window is reparented by the Docked container. | 87 // During a drag the window is reparented by the Docked container. |
| 91 WmWindow* drag_container = w1->GetRootWindow()->GetChildByShellWindowId( | 88 WmWindow* drag_container = w1->GetRootWindow()->GetChildByShellWindowId( |
| 92 kShellWindowId_DockedContainer); | 89 kShellWindowId_DockedContainer); |
| 93 drag_container->AddChild(w1); | 90 drag_container->AddChild(w1); |
| 94 EXPECT_TRUE(w1->GetWindowState()->is_dragged()); | 91 EXPECT_TRUE(w1->GetWindowState()->is_dragged()); |
| 95 | 92 |
| 96 // The dragged window should only be in the list once. | 93 // The dragged window should only be in the list once. |
| 97 WmWindow::Windows window_list = | 94 WmWindow::Windows window_list = |
| 98 mru_window_tracker()->BuildWindowListIgnoreModal(); | 95 mru_window_tracker()->BuildWindowListIgnoreModal(); |
| 99 EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(), w1)); | 96 EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(), w1)); |
| 100 } | 97 } |
| 101 | 98 |
| 102 } // namespace ash | 99 } // namespace ash |
| OLD | NEW |