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

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

Issue 13993027: ash: Update app list button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for #1 Created 7 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 | Annotate | Revision Log
« no previous file with comments | « ash/launcher/app_list_button.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.h" 5 #include "ash/launcher/launcher.h"
6
7 #include <vector>
8
9 #include "ash/launcher/app_list_button.h"
6 #include "ash/launcher/launcher_button.h" 10 #include "ash/launcher/launcher_button.h"
7 #include "ash/launcher/launcher_model.h" 11 #include "ash/launcher/launcher_model.h"
8 #include "ash/launcher/launcher_view.h" 12 #include "ash/launcher/launcher_view.h"
9
10 #include "ash/shelf/shelf_widget.h" 13 #include "ash/shelf/shelf_widget.h"
11 #include "ash/shell.h" 14 #include "ash/shell.h"
12 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
13 #include "ash/test/launcher_view_test_api.h" 16 #include "ash/test/launcher_view_test_api.h"
14 #include "ash/wm/window_util.h" 17 #include "ash/wm/window_util.h"
15 #include "ui/aura/root_window.h" 18 #include "ui/aura/root_window.h"
16 #include "ui/gfx/display.h" 19 #include "ui/gfx/display.h"
17 #include "ui/gfx/screen.h" 20 #include "ui/gfx/screen.h"
18 #include "ui/views/corewm/corewm_switches.h" 21 #include "ui/views/corewm/corewm_switches.h"
19 #include "ui/views/view.h" 22 #include "ui/views/view.h"
20 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
21 24
22 #if defined(OS_WIN) 25 #if defined(OS_WIN)
23 #include "base/win/windows_version.h" 26 #include "base/win/windows_version.h"
24 #endif 27 #endif
25 28
26 typedef ash::test::AshTestBase LauncherTest; 29 typedef ash::test::AshTestBase LauncherTest;
30 using ash::internal::AppListButton;
27 using ash::internal::LauncherView; 31 using ash::internal::LauncherView;
28 using ash::internal::LauncherButton; 32 using ash::internal::LauncherButton;
29 33
30 namespace ash { 34 namespace ash {
31 35
32 // Confirm that launching a browser gets the appropriate state reflected in 36 // Confirm that launching a browser gets the appropriate state reflected in
33 // its button. 37 // its button.
34 TEST_F(LauncherTest, OpenBrowser) { 38 TEST_F(LauncherTest, OpenBrowser) {
35 Launcher* launcher = Launcher::ForPrimaryDisplay(); 39 Launcher* launcher = Launcher::ForPrimaryDisplay();
36 ASSERT_TRUE(launcher); 40 ASSERT_TRUE(launcher);
(...skipping 13 matching lines...) Expand all
50 LauncherButton* button = test.GetButton(index); 54 LauncherButton* button = test.GetButton(index);
51 EXPECT_EQ(LauncherButton::STATE_RUNNING, button->state()); 55 EXPECT_EQ(LauncherButton::STATE_RUNNING, button->state());
52 56
53 // Remove it. 57 // Remove it.
54 model->RemoveItemAt(index); 58 model->RemoveItemAt(index);
55 ASSERT_EQ(--button_count, test.GetButtonCount()); 59 ASSERT_EQ(--button_count, test.GetButtonCount());
56 } 60 }
57 61
58 // Confirm that using the menu will clear the hover attribute. To avoid another 62 // Confirm that using the menu will clear the hover attribute. To avoid another
59 // browser test we check this here. 63 // browser test we check this here.
60 TEST_F(LauncherTest, checkHoverAfterMenu) { 64 TEST_F(LauncherTest, CheckHoverAfterMenu) {
61 Launcher* launcher = Launcher::ForPrimaryDisplay(); 65 Launcher* launcher = Launcher::ForPrimaryDisplay();
62 ASSERT_TRUE(launcher); 66 ASSERT_TRUE(launcher);
63 LauncherView* launcher_view = launcher->GetLauncherViewForTest(); 67 LauncherView* launcher_view = launcher->GetLauncherViewForTest();
64 test::LauncherViewTestAPI test(launcher_view); 68 test::LauncherViewTestAPI test(launcher_view);
65 LauncherModel* model = launcher_view->model(); 69 LauncherModel* model = launcher_view->model();
66 70
67 // Initially we have the app list and chrome icon. 71 // Initially we have the app list and chrome icon.
68 int button_count = test.GetButtonCount(); 72 int button_count = test.GetButtonCount();
69 73
70 // Add running tab. 74 // Add running tab.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 EXPECT_TRUE(launcher->IsShowingOverflowBubble()); 113 EXPECT_TRUE(launcher->IsShowingOverflowBubble());
110 114
111 // Removes the first item in main launcher view. 115 // Removes the first item in main launcher view.
112 model->RemoveItemAt(model->ItemIndexByID(first_item_id)); 116 model->RemoveItemAt(model->ItemIndexByID(first_item_id));
113 117
114 // Waits for all transitions to finish and there should be no crash. 118 // Waits for all transitions to finish and there should be no crash.
115 test.RunMessageLoopUntilAnimationsDone(); 119 test.RunMessageLoopUntilAnimationsDone();
116 EXPECT_FALSE(launcher->IsShowingOverflowBubble()); 120 EXPECT_FALSE(launcher->IsShowingOverflowBubble());
117 } 121 }
118 122
123 // Tests app list button toggles when app list UI shows up.
124 TEST_F(LauncherTest, AppMenuToggle) {
125 AppListButton* app_list_button = static_cast<AppListButton*>(
126 Launcher::ForPrimaryDisplay()->GetLauncherViewForTest()->
127 GetAppListButtonView());
128 Shell* shell = Shell::GetInstance();
129
130 EXPECT_FALSE(shell->GetAppListTargetVisibility());
131 EXPECT_FALSE(app_list_button->toggled());
132 shell->ToggleAppList(NULL);
133 EXPECT_TRUE(shell->GetAppListTargetVisibility());
134 EXPECT_TRUE(app_list_button->toggled());
135 }
136
137 // Tests only the app list button with a UI is toggled.
138 TEST_F(LauncherTest, MultipleAppMenuToggle) {
139 UpdateDisplay("300x300,200x200");
140
141 std::vector<AppListButton*> app_list_buttons;
142 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
143 for (Shell::RootWindowList::const_iterator it = root_windows.begin();
144 it != root_windows.end(); ++it) {
145 AppListButton* button = static_cast<AppListButton*>(
146 Launcher::ForWindow(*it)->GetLauncherViewForTest()->
147 GetAppListButtonView());
148 app_list_buttons.push_back(button);
149 EXPECT_FALSE(button->toggled());
150 }
151
152 Shell* shell = Shell::GetInstance();
153
154 EXPECT_FALSE(shell->GetAppListTargetVisibility());
155 shell->ToggleAppList(root_windows[0]);
156 EXPECT_TRUE(shell->GetAppListTargetVisibility());
157 EXPECT_TRUE(app_list_buttons[0]->toggled());
158 EXPECT_FALSE(app_list_buttons[1]->toggled());
159
160 shell->ToggleAppList(NULL);
161 EXPECT_FALSE(shell->GetAppListTargetVisibility());
162
163 shell->ToggleAppList(root_windows[1]);
164 EXPECT_TRUE(shell->GetAppListTargetVisibility());
165 EXPECT_FALSE(app_list_buttons[0]->toggled());
166 EXPECT_TRUE(app_list_buttons[1]->toggled());
167 }
168
119 } // namespace ash 169 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/app_list_button.cc ('k') | ash/launcher/launcher_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698