OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/launcher/launcher_navigator.h" | 5 #include "ash/launcher/launcher_navigator.h" |
6 | 6 |
7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
9 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 DISALLOW_COPY_AND_ASSIGN(LauncherNavigatorTest); | 52 DISALLOW_COPY_AND_ASSIGN(LauncherNavigatorTest); |
53 }; | 53 }; |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 TEST_F(LauncherNavigatorTest, BasicCycle) { | 57 TEST_F(LauncherNavigatorTest, BasicCycle) { |
58 // An app shortcut and three windows | 58 // An app shortcut and three windows |
59 LauncherItemType types[] = { | 59 LauncherItemType types[] = { |
60 TYPE_APP_SHORTCUT, TYPE_TABBED, TYPE_TABBED, TYPE_TABBED, | 60 TYPE_APP_SHORTCUT, TYPE_TABBED, TYPE_TABBED, TYPE_TABBED, |
61 }; | 61 }; |
62 // LauncherModel automatically adds BROWSER_SHORTCUT item at the | 62 // LauncherModel automatically adds BROWSER_SHORTCUT and APP_LIST items at the |
63 // beginning, so '2' refers the first TYPE_TABBED item. | 63 // beginning, so '3' refers the first TYPE_TABBED item. |
64 SetupMockLauncherModel(types, arraysize(types), 2); | 64 SetupMockLauncherModel(types, arraysize(types), 3); |
65 | 65 |
66 EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); | 66 EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); |
67 | 67 |
68 // Fourth one. It will skip the APP_SHORTCUT at the beginning of the list and | 68 // Fourth one. It will skip the APP_SHORTCUT at the beginning of the list and |
69 // the APP_LIST item which is automatically added at the end of items. | 69 // the APP_LIST item which is automatically added at the end of items. |
70 EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); | 70 EXPECT_EQ(5, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); |
71 } | 71 } |
72 | 72 |
73 TEST_F(LauncherNavigatorTest, WrapToBeginning) { | 73 TEST_F(LauncherNavigatorTest, WrapToBeginning) { |
74 LauncherItemType types[] = { | 74 LauncherItemType types[] = { |
75 TYPE_APP_SHORTCUT, TYPE_TABBED, TYPE_TABBED, TYPE_TABBED, | 75 TYPE_APP_SHORTCUT, TYPE_TABBED, TYPE_TABBED, TYPE_TABBED, |
76 }; | 76 }; |
77 SetupMockLauncherModel(types, arraysize(types), 4); | 77 SetupMockLauncherModel(types, arraysize(types), 5); |
78 | 78 |
79 // Second one. It skips the APP_LIST item at the end of the list, | 79 // Second one. It starts at the end, wraps to the beginning, and skips |
80 // wraps to the beginning, and skips BROWSER_SHORTCUT and APP_SHORTCUT | 80 // APP_LIST, BROWSER_SHORTCUT and APP_SHORTCUT at the beginning of the list. |
81 // at the beginning of the list. | 81 EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); |
82 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); | |
83 } | 82 } |
84 | 83 |
85 TEST_F(LauncherNavigatorTest, Empty) { | 84 TEST_F(LauncherNavigatorTest, Empty) { |
86 SetupMockLauncherModel(NULL, 0, -1); | 85 SetupMockLauncherModel(NULL, 0, -1); |
87 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); | 86 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); |
88 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); | 87 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); |
89 } | 88 } |
90 | 89 |
91 TEST_F(LauncherNavigatorTest, SingleEntry) { | 90 TEST_F(LauncherNavigatorTest, SingleEntry) { |
92 LauncherItemType type = TYPE_TABBED; | 91 LauncherItemType type = TYPE_TABBED; |
93 SetupMockLauncherModel(&type, 1, 1); | 92 SetupMockLauncherModel(&type, 1, 2); |
94 | 93 |
95 // If there's only one item there and it is already active, there's no item | 94 // If there's only one item there and it is already active, there's no item |
96 // to be activated next. | 95 // to be activated next. |
97 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); | 96 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); |
98 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); | 97 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); |
99 } | 98 } |
100 | 99 |
101 TEST_F(LauncherNavigatorTest, NoActive) { | 100 TEST_F(LauncherNavigatorTest, NoActive) { |
102 LauncherItemType types[] = { | 101 LauncherItemType types[] = { |
103 TYPE_TABBED, TYPE_TABBED, | 102 TYPE_TABBED, TYPE_TABBED, |
104 }; | 103 }; |
105 // Special case: no items are 'STATUS_ACTIVE'. | 104 // Special case: no items are 'STATUS_ACTIVE'. |
106 SetupMockLauncherModel(types, arraysize(types), -1); | 105 SetupMockLauncherModel(types, arraysize(types), -1); |
107 | 106 |
108 // If there are no active status, pick the first running item as a fallback. | 107 // If there are no active status, pick the first running item as a fallback. |
109 EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); | 108 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); |
110 EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); | 109 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); |
111 } | 110 } |
112 | 111 |
113 } // namespace ash | 112 } // namespace ash |
OLD | NEW |