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

Side by Side Diff: ash/shelf/shelf_navigator_unittest.cc

Issue 198063003: Revert of Shelf Cleanup (- binary files) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/shelf/shelf_model_unittest.cc ('k') | ash/shelf/shelf_view.h » ('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 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/shelf/shelf_navigator.h" 5 #include "ash/shelf/shelf_navigator.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/shelf/shelf.h" 8 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_item_types.h" 9 #include "ash/shelf/shelf_item_types.h"
10 #include "ash/shelf/shelf_model.h" 10 #include "ash/shelf/shelf_model.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 const ShelfModel& model() { return *model_.get(); } 64 const ShelfModel& model() { return *model_.get(); }
65 65
66 private: 66 private:
67 scoped_ptr<ShelfModel> model_; 67 scoped_ptr<ShelfModel> model_;
68 68
69 DISALLOW_COPY_AND_ASSIGN(ShelfNavigatorTest); 69 DISALLOW_COPY_AND_ASSIGN(ShelfNavigatorTest);
70 }; 70 };
71 71
72 class ShelfNavigatorLegacyShelfLayoutTest : public ShelfNavigatorTest {
73 public:
74 ShelfNavigatorLegacyShelfLayoutTest() : ShelfNavigatorTest() {}
75
76 protected:
77 virtual void SetUp() OVERRIDE {
78 CommandLine::ForCurrentProcess()->AppendSwitch(
79 switches::kAshDisableAlternateShelfLayout);
80 ShelfNavigatorTest::SetUp();
81 }
82
83 private:
84 DISALLOW_COPY_AND_ASSIGN(ShelfNavigatorLegacyShelfLayoutTest);
85 };
86
72 } // namespace 87 } // namespace
73 88
74 TEST_F(ShelfNavigatorTest, BasicCycle) { 89 TEST_F(ShelfNavigatorTest, BasicCycle) {
75 // An app shortcut and three platform apps. 90 // An app shortcut and three platform apps.
76 ShelfItemType types[] = { 91 ShelfItemType types[] = {
77 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, 92 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
78 }; 93 };
79 // ShelfModel automatically adds BROWSER_SHORTCUT item at the 94 // ShelfModel automatically adds BROWSER_SHORTCUT item at the
80 // beginning, so '3' refers the first TYPE_PLATFORM_APP item. 95 // beginning, so '3' refers the first TYPE_PLATFORM_APP item.
81 SetupMockShelfModel(types, arraysize(types), 3); 96 SetupMockShelfModel(types, arraysize(types), 3);
82 97
83 EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 98 EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
84 99
85 // Fourth one. It will skip the APP_SHORTCUT at the beginning of the list and 100 // Fourth one. It will skip the APP_SHORTCUT at the beginning of the list and
86 // the APP_LIST item which is automatically added at the end of items. 101 // the APP_LIST item which is automatically added at the end of items.
87 EXPECT_EQ(5, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 102 EXPECT_EQ(5, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
88 } 103 }
89 104
105 TEST_F(ShelfNavigatorLegacyShelfLayoutTest, BasicCycle) {
106 // An app shortcut and three platform apps.
107 ShelfItemType types[] = {
108 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
109 };
110 // ShelfModel automatically adds BROWSER_SHORTCUT item at the
111 // beginning, so '2' refers the first TYPE_PLATFORM_APP item.
112 SetupMockShelfModel(types, arraysize(types), 2);
113
114 EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
115
116 // Fourth one. It will skip the APP_SHORTCUT at the beginning of the list and
117 // the APP_LIST item which is automatically added at the end of items.
118 EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
119 }
120
90 TEST_F(ShelfNavigatorTest, WrapToBeginning) { 121 TEST_F(ShelfNavigatorTest, WrapToBeginning) {
91 ShelfItemType types[] = { 122 ShelfItemType types[] = {
92 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, 123 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
93 }; 124 };
94 SetupMockShelfModel(types, arraysize(types), 5); 125 SetupMockShelfModel(types, arraysize(types), 5);
95 126
96 // Second one. It skips the APP_LIST item at the end of the list, 127 // Second one. It skips the APP_LIST item at the end of the list,
97 // wraps to the beginning, and skips BROWSER_SHORTCUT and APP_SHORTCUT 128 // wraps to the beginning, and skips BROWSER_SHORTCUT and APP_SHORTCUT
98 // at the beginning of the list. 129 // at the beginning of the list.
99 EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 130 EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
100 } 131 }
101 132
133 TEST_F(ShelfNavigatorLegacyShelfLayoutTest, WrapToBeginning) {
134 ShelfItemType types[] = {
135 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
136 };
137 SetupMockShelfModel(types, arraysize(types), 4);
138
139 // Second one. It skips the APP_LIST item at the end of the list,
140 // wraps to the beginning, and skips BROWSER_SHORTCUT and APP_SHORTCUT
141 // at the beginning of the list.
142 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
143 }
144
102 TEST_F(ShelfNavigatorTest, Empty) { 145 TEST_F(ShelfNavigatorTest, Empty) {
103 SetupMockShelfModel(NULL, 0, -1); 146 SetupMockShelfModel(NULL, 0, -1);
104 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 147 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
105 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 148 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
106 } 149 }
107 150
108 TEST_F(ShelfNavigatorTest, SingleEntry) { 151 TEST_F(ShelfNavigatorTest, SingleEntry) {
109 ShelfItemType type = TYPE_PLATFORM_APP; 152 ShelfItemType type = TYPE_PLATFORM_APP;
110 SetupMockShelfModel(&type, 1, 2); 153 SetupMockShelfModel(&type, 1, 2);
111 154
112 // If there's only one item there and it is already active, there's no item 155 // If there's only one item there and it is already active, there's no item
113 // to be activated next. 156 // to be activated next.
157 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
158 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
159 }
160
161 TEST_F(ShelfNavigatorLegacyShelfLayoutTest, SingleEntry) {
162 ShelfItemType type = TYPE_PLATFORM_APP;
163 SetupMockShelfModel(&type, 1, 1);
164
165 // If there's only one item there and it is already active, there's no item
166 // to be activated next.
114 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 167 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
115 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 168 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
116 } 169 }
117 170
118 TEST_F(ShelfNavigatorTest, NoActive) { 171 TEST_F(ShelfNavigatorTest, NoActive) {
119 ShelfItemType types[] = { 172 ShelfItemType types[] = {
120 TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, 173 TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
121 }; 174 };
122 // Special case: no items are 'STATUS_ACTIVE'. 175 // Special case: no items are 'STATUS_ACTIVE'.
123 SetupMockShelfModel(types, arraysize(types), -1); 176 SetupMockShelfModel(types, arraysize(types), -1);
124 177
125 // If there are no active status, pick the first running item as a fallback. 178 // If there are no active status, pick the first running item as a fallback.
126 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 179 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
127 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 180 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
128 } 181 }
129 182
183 TEST_F(ShelfNavigatorLegacyShelfLayoutTest, NoActive) {
184 ShelfItemType types[] = {
185 TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
186 };
187 // Special case: no items are 'STATUS_ACTIVE'.
188 SetupMockShelfModel(types, arraysize(types), -1);
189
190 // If there are no active status, pick the first running item as a fallback.
191 EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
192 EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
193 }
194
130 } // namespace ash 195 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_model_unittest.cc ('k') | ash/shelf/shelf_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698