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

Side by Side Diff: ash/launcher/launcher_navigator_unittest.cc

Issue 22793011: ash:Shelf - Enable Alternate Shelf and Side Shelf by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ash/launcher/launcher_model_unittest.cc ('k') | ash/launcher/launcher_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ash_switches.h"
7 #include "ash/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
8 #include "ash/launcher/launcher_model.h" 9 #include "ash/launcher/launcher_model.h"
9 #include "ash/launcher/launcher_types.h" 10 #include "ash/launcher/launcher_types.h"
11 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 14
13 namespace ash { 15 namespace ash {
14 16
15 namespace { 17 namespace {
16 18
17 class LauncherNavigatorTest : public testing::Test { 19 class LauncherNavigatorTest : public testing::Test {
18 public: 20 public:
19 LauncherNavigatorTest() {} 21 LauncherNavigatorTest() {}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 57 }
56 58
57 const LauncherModel& model() { return *model_.get(); } 59 const LauncherModel& model() { return *model_.get(); }
58 60
59 private: 61 private:
60 scoped_ptr<LauncherModel> model_; 62 scoped_ptr<LauncherModel> model_;
61 63
62 DISALLOW_COPY_AND_ASSIGN(LauncherNavigatorTest); 64 DISALLOW_COPY_AND_ASSIGN(LauncherNavigatorTest);
63 }; 65 };
64 66
65 } // namespace 67 class LauncherNavigatorLegacyShelfLayoutTest : public LauncherNavigatorTest {
68 public:
69 LauncherNavigatorLegacyShelfLayoutTest() : LauncherNavigatorTest() {}
70
71 protected:
72 virtual void SetUp() OVERRIDE {
73 CommandLine::ForCurrentProcess()->AppendSwitch(
74 ash::switches::kAshDisableAlternateShelfLayout);
75 LauncherNavigatorTest::SetUp();
76 }
77
78 private:
79 DISALLOW_COPY_AND_ASSIGN(LauncherNavigatorLegacyShelfLayoutTest);
80 };
81
82 } // namespace
66 83
67 TEST_F(LauncherNavigatorTest, BasicCycle) { 84 TEST_F(LauncherNavigatorTest, BasicCycle) {
68 // An app shortcut and three platform apps. 85 // An app shortcut and three platform apps.
69 LauncherItemType types[] = { 86 LauncherItemType types[] = {
70 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, 87 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
71 }; 88 };
72 // LauncherModel automatically adds BROWSER_SHORTCUT item at the 89 // LauncherModel automatically adds BROWSER_SHORTCUT item at the
90 // beginning, so '3' refers the first TYPE_PLATFORM_APP item.
91 SetupMockLauncherModel(types, arraysize(types), 3);
92
93 EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
94
95 // Fourth one. It will skip the APP_SHORTCUT at the beginning of the list and
96 // the APP_LIST item which is automatically added at the end of items.
97 EXPECT_EQ(5, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
98 }
99
100 TEST_F(LauncherNavigatorLegacyShelfLayoutTest, BasicCycle) {
101 // An app shortcut and three platform apps.
102 LauncherItemType types[] = {
103 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
104 };
105 // LauncherModel automatically adds BROWSER_SHORTCUT item at the
73 // beginning, so '2' refers the first TYPE_PLATFORM_APP item. 106 // beginning, so '2' refers the first TYPE_PLATFORM_APP item.
74 SetupMockLauncherModel(types, arraysize(types), 2); 107 SetupMockLauncherModel(types, arraysize(types), 2);
75 108
76 EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 109 EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
77 110
78 // Fourth one. It will skip the APP_SHORTCUT at the beginning of the list and 111 // Fourth one. It will skip the APP_SHORTCUT at the beginning of the list and
79 // the APP_LIST item which is automatically added at the end of items. 112 // the APP_LIST item which is automatically added at the end of items.
80 EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 113 EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
81 } 114 }
82 115
83 TEST_F(LauncherNavigatorTest, WrapToBeginning) { 116 TEST_F(LauncherNavigatorTest, WrapToBeginning) {
84 LauncherItemType types[] = { 117 LauncherItemType types[] = {
85 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, 118 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
86 }; 119 };
120 SetupMockLauncherModel(types, arraysize(types), 5);
121
122 // Second one. It skips the APP_LIST item at the end of the list,
123 // wraps to the beginning, and skips BROWSER_SHORTCUT and APP_SHORTCUT
124 // at the beginning of the list.
125 EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
126 }
127
128 TEST_F(LauncherNavigatorLegacyShelfLayoutTest, WrapToBeginning) {
129 LauncherItemType types[] = {
130 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
131 };
87 SetupMockLauncherModel(types, arraysize(types), 4); 132 SetupMockLauncherModel(types, arraysize(types), 4);
88 133
89 // Second one. It skips the APP_LIST item at the end of the list, 134 // Second one. It skips the APP_LIST item at the end of the list,
90 // wraps to the beginning, and skips BROWSER_SHORTCUT and APP_SHORTCUT 135 // wraps to the beginning, and skips BROWSER_SHORTCUT and APP_SHORTCUT
91 // at the beginning of the list. 136 // at the beginning of the list.
92 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 137 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
93 } 138 }
94 139
95 TEST_F(LauncherNavigatorTest, Empty) { 140 TEST_F(LauncherNavigatorTest, Empty) {
96 SetupMockLauncherModel(NULL, 0, -1); 141 SetupMockLauncherModel(NULL, 0, -1);
97 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 142 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
98 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 143 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
99 } 144 }
100 145
101 TEST_F(LauncherNavigatorTest, SingleEntry) { 146 TEST_F(LauncherNavigatorTest, SingleEntry) {
102 LauncherItemType type = TYPE_PLATFORM_APP; 147 LauncherItemType type = TYPE_PLATFORM_APP;
148 SetupMockLauncherModel(&type, 1, 2);
149
150 // If there's only one item there and it is already active, there's no item
151 // to be activated next.
152 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
153 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
154 }
155
156 TEST_F(LauncherNavigatorLegacyShelfLayoutTest, SingleEntry) {
157 LauncherItemType type = TYPE_PLATFORM_APP;
103 SetupMockLauncherModel(&type, 1, 1); 158 SetupMockLauncherModel(&type, 1, 1);
104 159
105 // If there's only one item there and it is already active, there's no item 160 // If there's only one item there and it is already active, there's no item
106 // to be activated next. 161 // to be activated next.
107 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 162 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
108 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 163 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
109 } 164 }
110 165
111 TEST_F(LauncherNavigatorTest, NoActive) { 166 TEST_F(LauncherNavigatorTest, NoActive) {
112 LauncherItemType types[] = { 167 LauncherItemType types[] = {
113 TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, 168 TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
114 }; 169 };
115 // Special case: no items are 'STATUS_ACTIVE'. 170 // Special case: no items are 'STATUS_ACTIVE'.
116 SetupMockLauncherModel(types, arraysize(types), -1); 171 SetupMockLauncherModel(types, arraysize(types), -1);
117 172
118 // If there are no active status, pick the first running item as a fallback. 173 // If there are no active status, pick the first running item as a fallback.
174 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
175 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
176 }
177
178 TEST_F(LauncherNavigatorLegacyShelfLayoutTest, NoActive) {
179 LauncherItemType types[] = {
180 TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
181 };
182 // Special case: no items are 'STATUS_ACTIVE'.
183 SetupMockLauncherModel(types, arraysize(types), -1);
184
185 // If there are no active status, pick the first running item as a fallback.
119 EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 186 EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
120 EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 187 EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
121 } 188 }
122 189
123 } // namespace ash 190 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/launcher_model_unittest.cc ('k') | ash/launcher/launcher_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698