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

Side by Side Diff: chrome/browser/ui/views/ash/launcher/launcher_platform_app_browsertest.cc

Issue 10541109: Implement active window list for platform apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor cleanup Created 8 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 | Annotate | Revision Log
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 #include "ash/launcher/launcher_model.h" 6 #include "ash/launcher/launcher_model.h"
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/window_util.h" 8 #include "ash/wm/window_util.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 ASSERT_EQ(item_count, launcher->model()->item_count()); 161 ASSERT_EQ(item_count, launcher->model()->item_count());
162 // First app should be active again. 162 // First app should be active again.
163 ASSERT_EQ(ash::STATUS_ACTIVE, launcher->model()->ItemByID(item_id1)->status); 163 ASSERT_EQ(ash::STATUS_ACTIVE, launcher->model()->ItemByID(item_id1)->status);
164 164
165 // Close first app. 165 // Close first app.
166 CloseShellWindow(window1); 166 CloseShellWindow(window1);
167 --item_count; 167 --item_count;
168 ASSERT_EQ(item_count, launcher->model()->item_count()); 168 ASSERT_EQ(item_count, launcher->model()->item_count());
169 169
170 } 170 }
171
172 // Confirm that app windows can be reactivated by clicking their icons and that
173 // the correct activation order is maintained.
174 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) {
175 ash::Launcher* launcher = ash::Shell::GetInstance()->launcher();
176 int item_count = launcher->model()->item_count();
177
178 // First run app.
179 const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
180 ShellWindow* window1 = CreateShellWindow(extension1);
181 ++item_count;
182 ASSERT_EQ(item_count, launcher->model()->item_count());
183 ash::LauncherItem item1 =
184 launcher->model()->items()[launcher->model()->item_count() - 2];
185 ash::LauncherID item_id1 = item1.id;
186 ASSERT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
sky 2012/06/12 04:32:11 EXPECT_EQ is fine here and almost all of these. Us
187 ASSERT_EQ(ash::STATUS_ACTIVE, item1.status);
188
189 // Then run second app.
190 const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2");
191 ShellWindow* window2 = CreateShellWindow(extension2);
192 ++item_count;
193 ASSERT_EQ(item_count, launcher->model()->item_count());
194 ash::LauncherItem item2 =
195 launcher->model()->items()[launcher->model()->item_count() - 2];
196 ash::LauncherID item_id2 = item2.id;
197 ASSERT_EQ(ash::TYPE_PLATFORM_APP, item2.type);
198 ASSERT_EQ(ash::STATUS_ACTIVE, item2.status);
199
200 ASSERT_NE(item_id1, item_id2);
201 ASSERT_EQ(ash::STATUS_RUNNING, launcher->model()->ItemByID(item_id1)->status);
202
203 // Activate first one.
204 launcher->ActivateLauncherItem(launcher->model()->ItemIndexByID(item_id1));
205 ASSERT_EQ(ash::STATUS_ACTIVE, launcher->model()->ItemByID(item_id1)->status);
206 ASSERT_EQ(ash::STATUS_RUNNING, launcher->model()->ItemByID(item_id2)->status);
207 ASSERT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
208 ASSERT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
209
210 // Activate second one.
211 launcher->ActivateLauncherItem(launcher->model()->ItemIndexByID(item_id2));
212 ASSERT_EQ(ash::STATUS_RUNNING, launcher->model()->ItemByID(item_id1)->status);
213 ASSERT_EQ(ash::STATUS_ACTIVE, launcher->model()->ItemByID(item_id2)->status);
214 ASSERT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
215 ASSERT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
216
217 // Add window for app1. This will activate it.
218 ShellWindow* window3 = CreateShellWindow(extension1);
219 ash::wm::ActivateWindow(window3->GetNativeWindow());
220 ASSERT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
221 ASSERT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
222 ASSERT_TRUE(ash::wm::IsActiveWindow(window3->GetNativeWindow()));
223
224 // Activate the second app again
225 launcher->ActivateLauncherItem(launcher->model()->ItemIndexByID(item_id2));
226 ASSERT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
227 ASSERT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
228 ASSERT_FALSE(ash::wm::IsActiveWindow(window3->GetNativeWindow()));
229
230 // Activate the first app app
231 launcher->ActivateLauncherItem(launcher->model()->ItemIndexByID(item_id1));
232 ASSERT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
233 ASSERT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
234 ASSERT_TRUE(ash::wm::IsActiveWindow(window3->GetNativeWindow()));
235
236 // Close second app.
237 CloseShellWindow(window2);
238 --item_count;
239 ASSERT_EQ(item_count, launcher->model()->item_count());
240 // First app should be active again.
241 ASSERT_EQ(ash::STATUS_ACTIVE, launcher->model()->ItemByID(item_id1)->status);
242
243 // Close first app.
244 CloseShellWindow(window3);
245 CloseShellWindow(window1);
246 --item_count;
247 ASSERT_EQ(item_count, launcher->model()->item_count());
248
249 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698