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

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

Issue 2276553002: arc: Open launcher after installing app from Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix browser_tests Created 4 years, 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/common/shelf/shelf_delegate.h" 5 #include "ash/common/shelf/shelf_delegate.h"
6 #include "ash/common/wm_shell.h" 6 #include "ash/common/wm_shell.h"
7 #include "ash/shelf/shelf_util.h" 7 #include "ash/shelf/shelf_util.h"
8 #include "ash/wm/window_util.h" 8 #include "ash/wm/window_util.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "chrome/browser/extensions/extension_browsertest.h" 11 #include "chrome/browser/extensions/extension_browsertest.h"
12 #include "chrome/browser/ui/app_list/app_list_service.h"
12 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
13 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 14 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
14 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" 15 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
16 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 17 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
17 #include "chromeos/chromeos_switches.h" 18 #include "chromeos/chromeos_switches.h"
18 #include "content/public/test/browser_test_utils.h" 19 #include "content/public/test/browser_test_utils.h"
19 #include "mojo/common/common_type_converters.h" 20 #include "mojo/common/common_type_converters.h"
20 21
21 namespace mojo { 22 namespace mojo {
(...skipping 15 matching lines...) Expand all
37 }; 38 };
38 39
39 } // namespace mojo 40 } // namespace mojo
40 41
41 namespace { 42 namespace {
42 43
43 const char kTestAppName[] = "Test Arc App"; 44 const char kTestAppName[] = "Test Arc App";
44 const char kTestAppName2[] = "Test Arc App 2"; 45 const char kTestAppName2[] = "Test Arc App 2";
45 const char kTestAppPackage[] = "test.arc.app.package"; 46 const char kTestAppPackage[] = "test.arc.app.package";
46 const char kTestAppActivity[] = "test.arc.app.package.activity"; 47 const char kTestAppActivity[] = "test.arc.app.package.activity";
47 const char kTestAppActivity2[] = "test.arc.app.package.activity2"; 48 const char kTestAppActivity2[] = "test.arc.gitapp.package.activity2";
48 constexpr int kAppAnimatedThresholdMs = 100; 49 constexpr int kAppAnimatedThresholdMs = 100;
49 50
50 std::string GetTestApp1Id() { 51 std::string GetTestApp1Id() {
51 return ArcAppListPrefs::GetAppId(kTestAppPackage, kTestAppActivity); 52 return ArcAppListPrefs::GetAppId(kTestAppPackage, kTestAppActivity);
52 } 53 }
53 54
54 std::string GetTestApp2Id() { 55 std::string GetTestApp2Id() {
55 return ArcAppListPrefs::GetAppId(kTestAppPackage, kTestAppActivity2); 56 return ArcAppListPrefs::GetAppId(kTestAppPackage, kTestAppActivity2);
56 } 57 }
57 58
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = 146 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
146 app_prefs()->GetApp(GetTestApp1Id()); 147 app_prefs()->GetApp(GetTestApp1Id());
147 ASSERT_TRUE(app_info); 148 ASSERT_TRUE(app_info);
148 EXPECT_TRUE(app_info->ready); 149 EXPECT_TRUE(app_info->ready);
149 if (multi_app) { 150 if (multi_app) {
150 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info2 = 151 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info2 =
151 app_prefs()->GetApp(GetTestApp2Id()); 152 app_prefs()->GetApp(GetTestApp2Id());
152 ASSERT_TRUE(app_info2); 153 ASSERT_TRUE(app_info2);
153 EXPECT_TRUE(app_info2->ready); 154 EXPECT_TRUE(app_info2->ready);
154 } 155 }
156 }
155 157
158 void SendPackageAdded(bool package_synced) {
156 arc::mojom::ArcPackageInfo package_info; 159 arc::mojom::ArcPackageInfo package_info;
157 package_info.package_name = kTestAppPackage; 160 package_info.package_name = kTestAppPackage;
158 package_info.package_version = 1; 161 package_info.package_version = 1;
159 package_info.last_backup_android_id = 1; 162 package_info.last_backup_android_id = 1;
160 package_info.last_backup_time = 1; 163 package_info.last_backup_time = 1;
161 package_info.sync = false; 164 package_info.sync = package_synced;
165 package_info.system = false;
162 app_host()->OnPackageAdded(arc::mojom::ArcPackageInfo::From(package_info)); 166 app_host()->OnPackageAdded(arc::mojom::ArcPackageInfo::From(package_info));
163 167
164 base::RunLoop().RunUntilIdle(); 168 base::RunLoop().RunUntilIdle();
165 } 169 }
166 170
167 void SendPackageUpdated(bool multi_app) { 171 void SendPackageUpdated(bool multi_app) {
168 app_host()->OnPackageAppListRefreshed(kTestAppPackage, 172 app_host()->OnPackageAppListRefreshed(kTestAppPackage,
169 GetTestAppsList(multi_app)); 173 GetTestAppsList(multi_app));
170 } 174 }
171 175
172 void SendPackageRemoved() { app_host()->OnPackageRemoved(kTestAppPackage); } 176 void SendPackageRemoved() { app_host()->OnPackageRemoved(kTestAppPackage); }
173 177
174 void StartInstance() { 178 void StartInstance() {
175 auth_service()->OnPrimaryUserProfilePrepared(profile()); 179 if (auth_service()->profile() != profile())
180 auth_service()->OnPrimaryUserProfilePrepared(profile());
176 app_instance_observer()->OnInstanceReady(); 181 app_instance_observer()->OnInstanceReady();
177 } 182 }
178 183
179 void StopInstance() { 184 void StopInstance() {
180 auth_service()->Shutdown(); 185 auth_service()->Shutdown();
181 app_instance_observer()->OnInstanceClosed(); 186 app_instance_observer()->OnInstanceClosed();
182 } 187 }
183 188
184 ArcAppListPrefs* app_prefs() { return ArcAppListPrefs::Get(profile()); } 189 ArcAppListPrefs* app_prefs() { return ArcAppListPrefs::Get(profile()); }
185 190
(...skipping 26 matching lines...) Expand all
212 217
213 TestAction test_action() const { return std::tr1::get<0>(GetParam()); } 218 TestAction test_action() const { return std::tr1::get<0>(GetParam()); }
214 219
215 private: 220 private:
216 DISALLOW_COPY_AND_ASSIGN(ArcAppDeferredLauncherBrowserTest); 221 DISALLOW_COPY_AND_ASSIGN(ArcAppDeferredLauncherBrowserTest);
217 }; 222 };
218 223
219 // This tests simulates normal workflow for starting Arc app in deferred mode. 224 // This tests simulates normal workflow for starting Arc app in deferred mode.
220 IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherBrowserTest, StartAppDeferred) { 225 IN_PROC_BROWSER_TEST_P(ArcAppDeferredLauncherBrowserTest, StartAppDeferred) {
221 // Install app to remember existing apps. 226 // Install app to remember existing apps.
227 StartInstance();
222 InstallTestApps(false); 228 InstallTestApps(false);
229 SendPackageAdded(false);
223 230
224 const std::string app_id = GetTestApp1Id(); 231 const std::string app_id = GetTestApp1Id();
225 if (is_pinned()) { 232 if (is_pinned()) {
226 shelf_delegate()->PinAppWithID(app_id); 233 shelf_delegate()->PinAppWithID(app_id);
227 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); 234 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id));
228 } else { 235 } else {
229 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); 236 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id));
230 } 237 }
231 238
232 StopInstance(); 239 StopInstance();
(...skipping 15 matching lines...) Expand all
248 // Launching non-ready Arc app creates item on shelf and spinning animation. 255 // Launching non-ready Arc app creates item on shelf and spinning animation.
249 arc::LaunchApp(profile(), app_id); 256 arc::LaunchApp(profile(), app_id);
250 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); 257 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id));
251 AppAnimatedWaiter(app_id).Wait(); 258 AppAnimatedWaiter(app_id).Wait();
252 259
253 switch (test_action()) { 260 switch (test_action()) {
254 case TEST_ACTION_START: 261 case TEST_ACTION_START:
255 // Now simulates that Arc is started and app list is refreshed. This 262 // Now simulates that Arc is started and app list is refreshed. This
256 // should stop animation and delete icon from the shelf. 263 // should stop animation and delete icon from the shelf.
257 InstallTestApps(false); 264 InstallTestApps(false);
265 SendPackageAdded(false);
258 EXPECT_TRUE(chrome_controller() 266 EXPECT_TRUE(chrome_controller()
259 ->GetArcDeferredLauncher() 267 ->GetArcDeferredLauncher()
260 ->GetActiveTime(app_id) 268 ->GetActiveTime(app_id)
261 .is_zero()); 269 .is_zero());
262 if (is_pinned()) 270 if (is_pinned())
263 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id)); 271 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id));
264 else 272 else
265 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id)); 273 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id));
266 break; 274 break;
267 case TEST_ACTION_EXIT: 275 case TEST_ACTION_EXIT:
(...skipping 19 matching lines...) Expand all
287 break; 295 break;
288 } 296 }
289 } 297 }
290 298
291 INSTANTIATE_TEST_CASE_P(ArcAppDeferredLauncherBrowserTestInstance, 299 INSTANTIATE_TEST_CASE_P(ArcAppDeferredLauncherBrowserTestInstance,
292 ArcAppDeferredLauncherBrowserTest, 300 ArcAppDeferredLauncherBrowserTest,
293 ::testing::ValuesIn(build_test_parameter)); 301 ::testing::ValuesIn(build_test_parameter));
294 302
295 // This tests validates pin state on package update and remove. 303 // This tests validates pin state on package update and remove.
296 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, PinOnPackageUpdateAndRemove) { 304 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, PinOnPackageUpdateAndRemove) {
305 StartInstance();
297 InstallTestApps(true); 306 InstallTestApps(true);
307 SendPackageAdded(false);
298 308
299 const std::string app_id1 = GetTestApp1Id(); 309 const std::string app_id1 = GetTestApp1Id();
300 const std::string app_id2 = GetTestApp2Id(); 310 const std::string app_id2 = GetTestApp2Id();
301 shelf_delegate()->PinAppWithID(app_id1); 311 shelf_delegate()->PinAppWithID(app_id1);
302 shelf_delegate()->PinAppWithID(app_id2); 312 shelf_delegate()->PinAppWithID(app_id2);
303 const ash::ShelfID shelf_id1_before = 313 const ash::ShelfID shelf_id1_before =
304 shelf_delegate()->GetShelfIDForAppID(app_id1); 314 shelf_delegate()->GetShelfIDForAppID(app_id1);
305 EXPECT_TRUE(shelf_id1_before); 315 EXPECT_TRUE(shelf_id1_before);
306 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id2)); 316 EXPECT_TRUE(shelf_delegate()->GetShelfIDForAppID(app_id2));
307 317
308 // Package contains only one app. 318 // Package contains only one app. App list is not shown for updated package.
309 SendPackageUpdated(false); 319 SendPackageUpdated(false);
310 // Second pin should gone. 320 // Second pin should gone.
311 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); 321 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1));
312 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); 322 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2));
313 323
314 // Package contains two apps. 324 // Package contains two apps. App list is not shown for updated package.
315 SendPackageUpdated(true); 325 SendPackageUpdated(true);
316 // Second pin should not appear. 326 // Second pin should not appear.
317 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1)); 327 EXPECT_EQ(shelf_id1_before, shelf_delegate()->GetShelfIDForAppID(app_id1));
318 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); 328 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2));
319 329
320 // Package removed. 330 // Package removed.
321 SendPackageRemoved(); 331 SendPackageRemoved();
322 // No pin is expected. 332 // No pin is expected.
323 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id1)); 333 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id1));
324 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2)); 334 EXPECT_FALSE(shelf_delegate()->GetShelfIDForAppID(app_id2));
325 } 335 }
336
337 // This test validates that app list is shown on new package and not shown
338 // on package update.
339 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, AppListShown) {
340 StartInstance();
341 AppListService* app_list_service = AppListService::Get();
342 ASSERT_TRUE(app_list_service);
343
344 EXPECT_FALSE(app_list_service->IsAppListVisible());
345
346 // New package is available. Show app list.
347 InstallTestApps(false);
348 SendPackageAdded(true);
349 EXPECT_TRUE(app_list_service->IsAppListVisible());
350
351 app_list_service->DismissAppList();
352 EXPECT_FALSE(app_list_service->IsAppListVisible());
353
354 // Send package update event. App list is not shown.
355 SendPackageAdded(true);
356 EXPECT_FALSE(app_list_service->IsAppListVisible());
357 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_package_syncable_service.cc ('k') | ui/app_list/views/app_list_main_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698