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

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

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « ash/shelf/shelf_navigator.cc ('k') | ash/shelf/shelf_unittest.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 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/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/shelf/shelf_item_types.h" 8 #include "ash/common/shelf/shelf_item_types.h"
9 #include "ash/common/shelf/shelf_model.h" 9 #include "ash/common/shelf/shelf_model.h"
10 #include "ash/shelf/shelf.h" 10 #include "ash/shelf/shelf.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 for (int i = 0; i < types_length; ++i) { 46 for (int i = 0; i < types_length; ++i) {
47 ShelfItem new_item; 47 ShelfItem new_item;
48 new_item.type = types[i]; 48 new_item.type = types[i];
49 new_item.status = 49 new_item.status =
50 (types[i] == TYPE_PLATFORM_APP) ? STATUS_RUNNING : STATUS_CLOSED; 50 (types[i] == TYPE_PLATFORM_APP) ? STATUS_RUNNING : STATUS_CLOSED;
51 model_->Add(new_item); 51 model_->Add(new_item);
52 } 52 }
53 53
54 // Set the focused item. 54 // Set the focused item.
55 if (focused_index >= 0) { 55 if (focused_index >= 0) {
56 ShelfItem focused_item =model_->items()[focused_index]; 56 ShelfItem focused_item = model_->items()[focused_index];
57 if (focused_item.type == TYPE_PLATFORM_APP) { 57 if (focused_item.type == TYPE_PLATFORM_APP) {
58 focused_item.status = STATUS_ACTIVE; 58 focused_item.status = STATUS_ACTIVE;
59 model_->Set(focused_index, focused_item); 59 model_->Set(focused_index, focused_item);
60 } 60 }
61 } 61 }
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 std::unique_ptr<ShelfModel> model_; 67 std::unique_ptr<ShelfModel> model_;
68 68
69 DISALLOW_COPY_AND_ASSIGN(ShelfNavigatorTest); 69 DISALLOW_COPY_AND_ASSIGN(ShelfNavigatorTest);
70 }; 70 };
71 71
72 } // namespace 72 } // namespace
73 73
74 TEST_F(ShelfNavigatorTest, BasicCycle) { 74 TEST_F(ShelfNavigatorTest, BasicCycle) {
75 // An app shortcut and three platform apps. 75 // An app shortcut and three platform apps.
76 ShelfItemType types[] = { 76 ShelfItemType types[] = {
77 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, 77 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
78 TYPE_PLATFORM_APP,
78 }; 79 };
79 // ShelfModel automatically adds BROWSER_SHORTCUT item at the 80 // ShelfModel automatically adds BROWSER_SHORTCUT item at the
80 // beginning, so '3' refers the first TYPE_PLATFORM_APP item. 81 // beginning, so '3' refers the first TYPE_PLATFORM_APP item.
81 SetupMockShelfModel(types, arraysize(types), 3); 82 SetupMockShelfModel(types, arraysize(types), 3);
82 83
83 EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 84 EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
84 85
85 // Fourth one. It will skip the APP_SHORTCUT at the beginning of the list and 86 // 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. 87 // the APP_LIST item which is automatically added at the end of items.
87 EXPECT_EQ(5, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 88 EXPECT_EQ(5, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
88 } 89 }
89 90
90 TEST_F(ShelfNavigatorTest, WrapToBeginning) { 91 TEST_F(ShelfNavigatorTest, WrapToBeginning) {
91 ShelfItemType types[] = { 92 ShelfItemType types[] = {
92 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, 93 TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
94 TYPE_PLATFORM_APP,
93 }; 95 };
94 SetupMockShelfModel(types, arraysize(types), 5); 96 SetupMockShelfModel(types, arraysize(types), 5);
95 97
96 // Second one. It skips the APP_LIST item at the end of the list, 98 // 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 99 // wraps to the beginning, and skips BROWSER_SHORTCUT and APP_SHORTCUT
98 // at the beginning of the list. 100 // at the beginning of the list.
99 EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 101 EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
100 } 102 }
101 103
102 TEST_F(ShelfNavigatorTest, Empty) { 104 TEST_F(ShelfNavigatorTest, Empty) {
103 SetupMockShelfModel(NULL, 0, -1); 105 SetupMockShelfModel(NULL, 0, -1);
104 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 106 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
105 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 107 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
106 } 108 }
107 109
108 TEST_F(ShelfNavigatorTest, SingleEntry) { 110 TEST_F(ShelfNavigatorTest, SingleEntry) {
109 ShelfItemType type = TYPE_PLATFORM_APP; 111 ShelfItemType type = TYPE_PLATFORM_APP;
110 SetupMockShelfModel(&type, 1, 2); 112 SetupMockShelfModel(&type, 1, 2);
111 113
112 // If there's only one item there and it is already active, there's no item 114 // If there's only one item there and it is already active, there's no item
113 // to be activated next. 115 // to be activated next.
114 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 116 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
115 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 117 EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
116 } 118 }
117 119
118 TEST_F(ShelfNavigatorTest, NoActive) { 120 TEST_F(ShelfNavigatorTest, NoActive) {
119 ShelfItemType types[] = { 121 ShelfItemType types[] = {
120 TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, 122 TYPE_PLATFORM_APP, TYPE_PLATFORM_APP,
121 }; 123 };
122 // Special case: no items are 'STATUS_ACTIVE'. 124 // Special case: no items are 'STATUS_ACTIVE'.
123 SetupMockShelfModel(types, arraysize(types), -1); 125 SetupMockShelfModel(types, arraysize(types), -1);
124 126
125 // If there are no active status, pick the first running item as a fallback. 127 // If there are no active status, pick the first running item as a fallback.
126 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); 128 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD));
127 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); 129 EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD));
128 } 130 }
129 131
130 } // namespace ash 132 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_navigator.cc ('k') | ash/shelf/shelf_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698