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

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

Issue 2860503002: mash: Replace int ShelfIDs with AppLaunchID strings. (Closed)
Patch Set: Fix struct traits typo. Created 3 years, 7 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_tooltip_manager_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 <utility> 5 #include <utility>
6 6
7 #include "ash/shelf/shelf_button.h" 7 #include "ash/shelf/shelf_button.h"
8 #include "ash/shelf/shelf_model.h" 8 #include "ash/shelf/shelf_model.h"
9 #include "ash/shelf/shelf_view.h" 9 #include "ash/shelf/shelf_view.h"
10 #include "ash/shelf/shelf_widget.h" 10 #include "ash/shelf/shelf_widget.h"
11 #include "ash/shelf/wm_shelf.h" 11 #include "ash/shelf/wm_shelf.h"
12 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
13 #include "ash/test/shelf_view_test_api.h" 13 #include "ash/test/shelf_view_test_api.h"
14 #include "base/strings/string_number_conversions.h"
14 15
15 namespace ash { 16 namespace ash {
16 17
17 class ShelfTest : public test::AshTestBase { 18 class ShelfTest : public test::AshTestBase {
18 public: 19 public:
19 ShelfTest() : shelf_model_(nullptr) {} 20 ShelfTest() : shelf_model_(nullptr) {}
20 21
21 ~ShelfTest() override {} 22 ~ShelfTest() override {}
22 23
23 void SetUp() override { 24 void SetUp() override {
(...skipping 16 matching lines...) Expand all
40 DISALLOW_COPY_AND_ASSIGN(ShelfTest); 41 DISALLOW_COPY_AND_ASSIGN(ShelfTest);
41 }; 42 };
42 43
43 // Confirms that ShelfItem reflects the appropriated state. 44 // Confirms that ShelfItem reflects the appropriated state.
44 TEST_F(ShelfTest, StatusReflection) { 45 TEST_F(ShelfTest, StatusReflection) {
45 // Initially we have the app list. 46 // Initially we have the app list.
46 int button_count = test_api()->GetButtonCount(); 47 int button_count = test_api()->GetButtonCount();
47 48
48 // Add a running app. 49 // Add a running app.
49 ShelfItem item; 50 ShelfItem item;
51 item.id = ShelfID("foo");
50 item.type = TYPE_APP; 52 item.type = TYPE_APP;
51 item.status = STATUS_RUNNING; 53 item.status = STATUS_RUNNING;
52 int index = shelf_model()->Add(item); 54 int index = shelf_model()->Add(item);
53 ASSERT_EQ(++button_count, test_api()->GetButtonCount()); 55 ASSERT_EQ(++button_count, test_api()->GetButtonCount());
54 ShelfButton* button = test_api()->GetButton(index); 56 ShelfButton* button = test_api()->GetButton(index);
55 EXPECT_EQ(ShelfButton::STATE_RUNNING, button->state()); 57 EXPECT_EQ(ShelfButton::STATE_RUNNING, button->state());
56 58
57 // Remove it. 59 // Remove it.
58 shelf_model()->RemoveItemAt(index); 60 shelf_model()->RemoveItemAt(index);
59 ASSERT_EQ(--button_count, test_api()->GetButtonCount()); 61 ASSERT_EQ(--button_count, test_api()->GetButtonCount());
60 } 62 }
61 63
62 // Confirm that using the menu will clear the hover attribute. To avoid another 64 // Confirm that using the menu will clear the hover attribute. To avoid another
63 // browser test we check this here. 65 // browser test we check this here.
64 TEST_F(ShelfTest, CheckHoverAfterMenu) { 66 TEST_F(ShelfTest, CheckHoverAfterMenu) {
65 // Initially we have the app list. 67 // Initially we have the app list.
66 int button_count = test_api()->GetButtonCount(); 68 int button_count = test_api()->GetButtonCount();
67 69
68 // Add a running app. 70 // Add a running app.
69 ShelfItem item; 71 ShelfItem item;
72 item.id = ShelfID("foo");
70 item.type = TYPE_APP; 73 item.type = TYPE_APP;
71 item.status = STATUS_RUNNING; 74 item.status = STATUS_RUNNING;
72 int index = shelf_model()->Add(item); 75 int index = shelf_model()->Add(item);
73 76
74 ASSERT_EQ(++button_count, test_api()->GetButtonCount()); 77 ASSERT_EQ(++button_count, test_api()->GetButtonCount());
75 ShelfButton* button = test_api()->GetButton(index); 78 ShelfButton* button = test_api()->GetButton(index);
76 button->AddState(ShelfButton::STATE_HOVERED); 79 button->AddState(ShelfButton::STATE_HOVERED);
77 button->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); 80 button->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
78 EXPECT_FALSE(button->state() & ShelfButton::STATE_HOVERED); 81 EXPECT_FALSE(button->state() & ShelfButton::STATE_HOVERED);
79 82
80 // Remove it. 83 // Remove it.
81 shelf_model()->RemoveItemAt(index); 84 shelf_model()->RemoveItemAt(index);
82 } 85 }
83 86
84 TEST_F(ShelfTest, ShowOverflowBubble) { 87 TEST_F(ShelfTest, ShowOverflowBubble) {
85 ShelfWidget* shelf_widget = GetPrimaryShelf()->shelf_widget(); 88 ShelfWidget* shelf_widget = GetPrimaryShelf()->shelf_widget();
86 ShelfID first_item_id = shelf_model()->next_id();
87 89
88 // Add app buttons until overflow occurs. 90 // Add app buttons until overflow occurs.
89 int items_added = 0; 91 ShelfItem item;
92 item.type = TYPE_APP;
93 item.status = STATUS_RUNNING;
90 while (!test_api()->IsOverflowButtonVisible()) { 94 while (!test_api()->IsOverflowButtonVisible()) {
91 ShelfItem item; 95 item.id = ShelfID(base::IntToString(shelf_model()->item_count()));
92 item.type = TYPE_APP;
93 item.status = STATUS_RUNNING;
94 shelf_model()->Add(item); 96 shelf_model()->Add(item);
95 97 ASSERT_LT(shelf_model()->item_count(), 10000);
96 ++items_added;
97 ASSERT_LT(items_added, 10000);
98 } 98 }
99 99
100 // Shows overflow bubble. 100 // Shows overflow bubble.
101 test_api()->ShowOverflowBubble(); 101 test_api()->ShowOverflowBubble();
102 EXPECT_TRUE(shelf_widget->IsShowingOverflowBubble()); 102 EXPECT_TRUE(shelf_widget->IsShowingOverflowBubble());
103 103
104 // Removes the first item in main shelf view. 104 // Remove one of the first items in the main shelf view.
105 shelf_model()->RemoveItemAt(shelf_model()->ItemIndexByID(first_item_id)); 105 ASSERT_GT(shelf_model()->item_count(), 1);
106 shelf_model()->RemoveItemAt(1);
106 107
107 // Waits for all transitions to finish and there should be no crash. 108 // Waits for all transitions to finish and there should be no crash.
108 test_api()->RunMessageLoopUntilAnimationsDone(); 109 test_api()->RunMessageLoopUntilAnimationsDone();
109 EXPECT_FALSE(shelf_widget->IsShowingOverflowBubble()); 110 EXPECT_FALSE(shelf_widget->IsShowingOverflowBubble());
110 } 111 }
111 112
112 } // namespace ash 113 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_tooltip_manager_unittest.cc ('k') | ash/shelf/shelf_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698