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

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

Issue 2860503002: mash: Replace int ShelfIDs with AppLaunchID strings. (Closed)
Patch Set: Restore AppLaunchId class via using ShelfID = AppLaunchId; cleanup. 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
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/public/cpp/shelf_item_delegate.h" 5 #include "ash/public/cpp/shelf_item_delegate.h"
6 #include "ash/shelf/shelf_model.h" 6 #include "ash/shelf/shelf_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/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // Install app to remember existing apps. 301 // Install app to remember existing apps.
302 StartInstance(); 302 StartInstance();
303 InstallTestApps(kTestAppPackage, false); 303 InstallTestApps(kTestAppPackage, false);
304 SendPackageAdded(kTestAppPackage, false); 304 SendPackageAdded(kTestAppPackage, false);
305 305
306 const std::string app_id = GetTestApp1Id(kTestAppPackage); 306 const std::string app_id = GetTestApp1Id(kTestAppPackage);
307 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); 307 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model();
308 if (is_pinned()) { 308 if (is_pinned()) {
309 shelf_model->PinAppWithID(app_id); 309 shelf_model->PinAppWithID(app_id);
310 const ash::ShelfID shelf_id = shelf_model->GetShelfIDForAppID(app_id); 310 const ash::ShelfID shelf_id = shelf_model->GetShelfIDForAppID(app_id);
311 EXPECT_TRUE(shelf_id); 311 EXPECT_FALSE(shelf_id.IsEmpty());
312 const ash::ShelfItem* item = chrome_controller()->GetItem(shelf_id); 312 const ash::ShelfItem* item = chrome_controller()->GetItem(shelf_id);
313 EXPECT_EQ(base::UTF8ToUTF16(kTestAppName), item->title); 313 EXPECT_EQ(base::UTF8ToUTF16(kTestAppName), item->title);
314 } else { 314 } else {
315 EXPECT_FALSE(shelf_model->GetShelfIDForAppID(app_id)); 315 EXPECT_TRUE(shelf_model->GetShelfIDForAppID(app_id).IsEmpty());
316 } 316 }
317 317
318 StopInstance(); 318 StopInstance();
319 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = 319 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
320 app_prefs()->GetApp(app_id); 320 app_prefs()->GetApp(app_id);
321 EXPECT_FALSE(app_info); 321 EXPECT_FALSE(app_info);
322 322
323 // Restart instance. App should be taken from prefs but its state is non-ready 323 // Restart instance. App should be taken from prefs but its state is non-ready
324 // currently. 324 // currently.
325 StartInstance(); 325 StartInstance();
326 app_info = app_prefs()->GetApp(app_id); 326 app_info = app_prefs()->GetApp(app_id);
327 ASSERT_TRUE(app_info); 327 ASSERT_TRUE(app_info);
328 EXPECT_FALSE(app_info->ready); 328 EXPECT_FALSE(app_info->ready);
329 if (is_pinned()) 329 EXPECT_NE(is_pinned(), shelf_model->GetShelfIDForAppID(app_id).IsEmpty());
330 EXPECT_TRUE(shelf_model->GetShelfIDForAppID(app_id));
331 else
332 EXPECT_FALSE(shelf_model->GetShelfIDForAppID(app_id));
333 330
334 // Launching non-ready ARC app creates item on shelf and spinning animation. 331 // Launching non-ready ARC app creates item on shelf and spinning animation.
335 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); 332 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON);
336 const ash::ShelfID shelf_id = shelf_model->GetShelfIDForAppID(app_id); 333 const ash::ShelfID shelf_id = shelf_model->GetShelfIDForAppID(app_id);
337 EXPECT_TRUE(shelf_id); 334 EXPECT_FALSE(shelf_id.IsEmpty());
338 const ash::ShelfItem* item = chrome_controller()->GetItem(shelf_id); 335 const ash::ShelfItem* item = chrome_controller()->GetItem(shelf_id);
339 EXPECT_EQ(base::UTF8ToUTF16(kTestAppName), item->title); 336 EXPECT_EQ(base::UTF8ToUTF16(kTestAppName), item->title);
340 AppAnimatedWaiter(app_id).Wait(); 337 AppAnimatedWaiter(app_id).Wait();
341 338
342 switch (test_action()) { 339 switch (test_action()) {
343 case TEST_ACTION_START: 340 case TEST_ACTION_START:
344 // Now simulates that ARC is started and app list is refreshed. This 341 // Now simulates that ARC is started and app list is refreshed. This
345 // should stop animation and delete icon from the shelf. 342 // should stop animation and delete icon from the shelf.
346 InstallTestApps(kTestAppPackage, false); 343 InstallTestApps(kTestAppPackage, false);
347 SendPackageAdded(kTestAppPackage, false); 344 SendPackageAdded(kTestAppPackage, false);
348 EXPECT_TRUE(chrome_controller() 345 EXPECT_TRUE(chrome_controller()
349 ->GetArcDeferredLauncher() 346 ->GetArcDeferredLauncher()
350 ->GetActiveTime(app_id) 347 ->GetActiveTime(app_id)
351 .is_zero()); 348 .is_zero());
352 if (is_pinned()) 349 EXPECT_NE(is_pinned(), shelf_model->GetShelfIDForAppID(app_id).IsEmpty());
353 EXPECT_TRUE(shelf_model->GetShelfIDForAppID(app_id));
354 else
355 EXPECT_FALSE(shelf_model->GetShelfIDForAppID(app_id));
356 break; 350 break;
357 case TEST_ACTION_EXIT: 351 case TEST_ACTION_EXIT:
358 // Just exist Chrome. 352 // Just exist Chrome.
359 break; 353 break;
360 case TEST_ACTION_CLOSE: 354 case TEST_ACTION_CLOSE:
361 // Close item during animation. 355 // Close item during animation.
362 { 356 ash::ShelfItemDelegate* delegate = GetShelfItemDelegate(app_id);
James Cook 2017/05/04 16:38:49 Huh, I'm surprised this compiles, since there's no
msw 2017/05/04 19:05:57 Why do you think the brackets are needed?
James Cook 2017/05/04 19:45:08 Because you're declaring a new variable but not ad
msw 2017/05/04 20:39:07 Done.
363 ash::ShelfItemDelegate* delegate = GetShelfItemDelegate(app_id); 357 ASSERT_TRUE(delegate);
364 ASSERT_TRUE(delegate); 358 delegate->Close();
365 delegate->Close(); 359 EXPECT_TRUE(chrome_controller()
366 EXPECT_TRUE(chrome_controller() 360 ->GetArcDeferredLauncher()
367 ->GetArcDeferredLauncher() 361 ->GetActiveTime(app_id)
368 ->GetActiveTime(app_id) 362 .is_zero());
369 .is_zero()); 363 EXPECT_NE(is_pinned(), shelf_model->GetShelfIDForAppID(app_id).IsEmpty());
370 if (is_pinned())
371 EXPECT_TRUE(shelf_model->GetShelfIDForAppID(app_id));
372 else
373 EXPECT_FALSE(shelf_model->GetShelfIDForAppID(app_id));
374 }
375 break; 364 break;
376 } 365 }
377 } 366 }
378 367
379 INSTANTIATE_TEST_CASE_P(ArcAppDeferredLauncherBrowserTestInstance, 368 INSTANTIATE_TEST_CASE_P(ArcAppDeferredLauncherBrowserTestInstance,
380 ArcAppDeferredLauncherBrowserTest, 369 ArcAppDeferredLauncherBrowserTest,
381 ::testing::ValuesIn(build_test_parameter)); 370 ::testing::ValuesIn(build_test_parameter));
382 371
383 // This tests validates pin state on package update and remove. 372 // This tests validates pin state on package update and remove.
384 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, PinOnPackageUpdateAndRemove) { 373 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, PinOnPackageUpdateAndRemove) {
385 StartInstance(); 374 StartInstance();
386 375
387 // Make use app list sync service is started. Normally it is started when 376 // Make use app list sync service is started. Normally it is started when
388 // sycing is initialized. 377 // sycing is initialized.
389 app_list::AppListSyncableServiceFactory::GetForProfile(profile())->GetModel(); 378 app_list::AppListSyncableServiceFactory::GetForProfile(profile())->GetModel();
390 379
391 InstallTestApps(kTestAppPackage, true); 380 InstallTestApps(kTestAppPackage, true);
392 SendPackageAdded(kTestAppPackage, false); 381 SendPackageAdded(kTestAppPackage, false);
393 382
394 const std::string app_id1 = GetTestApp1Id(kTestAppPackage); 383 const std::string app_id1 = GetTestApp1Id(kTestAppPackage);
395 const std::string app_id2 = GetTestApp2Id(kTestAppPackage); 384 const std::string app_id2 = GetTestApp2Id(kTestAppPackage);
396 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); 385 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model();
397 shelf_model->PinAppWithID(app_id1); 386 shelf_model->PinAppWithID(app_id1);
398 shelf_model->PinAppWithID(app_id2); 387 shelf_model->PinAppWithID(app_id2);
399 const ash::ShelfID shelf_id1_before = 388 const ash::ShelfID shelf_id1_before =
400 shelf_model->GetShelfIDForAppID(app_id1); 389 shelf_model->GetShelfIDForAppID(app_id1);
401 EXPECT_TRUE(shelf_id1_before); 390 EXPECT_FALSE(shelf_id1_before.IsEmpty());
402 EXPECT_TRUE(shelf_model->GetShelfIDForAppID(app_id2)); 391 EXPECT_FALSE(shelf_model->GetShelfIDForAppID(app_id2).IsEmpty());
403 392
404 // Package contains only one app. App list is not shown for updated package. 393 // Package contains only one app. App list is not shown for updated package.
405 SendPackageUpdated(kTestAppPackage, false); 394 SendPackageUpdated(kTestAppPackage, false);
406 // Second pin should gone. 395 // Second pin should gone.
407 EXPECT_EQ(shelf_id1_before, shelf_model->GetShelfIDForAppID(app_id1)); 396 EXPECT_EQ(shelf_id1_before, shelf_model->GetShelfIDForAppID(app_id1));
408 EXPECT_FALSE(shelf_model->GetShelfIDForAppID(app_id2)); 397 EXPECT_TRUE(shelf_model->GetShelfIDForAppID(app_id2).IsEmpty());
409 398
410 // Package contains two apps. App list is not shown for updated package. 399 // Package contains two apps. App list is not shown for updated package.
411 SendPackageUpdated(kTestAppPackage, true); 400 SendPackageUpdated(kTestAppPackage, true);
412 // Second pin should not appear. 401 // Second pin should not appear.
413 EXPECT_EQ(shelf_id1_before, shelf_model->GetShelfIDForAppID(app_id1)); 402 EXPECT_EQ(shelf_id1_before, shelf_model->GetShelfIDForAppID(app_id1));
414 EXPECT_FALSE(shelf_model->GetShelfIDForAppID(app_id2)); 403 EXPECT_TRUE(shelf_model->GetShelfIDForAppID(app_id2).IsEmpty());
415 404
416 // Package removed. 405 // Package removed.
417 SendPackageRemoved(kTestAppPackage); 406 SendPackageRemoved(kTestAppPackage);
418 // No pin is expected. 407 // No pin is expected.
419 EXPECT_FALSE(shelf_model->GetShelfIDForAppID(app_id1)); 408 EXPECT_TRUE(shelf_model->GetShelfIDForAppID(app_id1).IsEmpty());
420 EXPECT_FALSE(shelf_model->GetShelfIDForAppID(app_id2)); 409 EXPECT_TRUE(shelf_model->GetShelfIDForAppID(app_id2).IsEmpty());
421 } 410 }
422 411
423 // This test validates that app list is shown on new package and not shown 412 // This test validates that app list is shown on new package and not shown
424 // on package update. 413 // on package update.
425 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, AppListShown) { 414 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, AppListShown) {
426 StartInstance(); 415 StartInstance();
427 AppListService* app_list_service = AppListService::Get(); 416 AppListService* app_list_service = AppListService::Get();
428 ASSERT_TRUE(app_list_service); 417 ASSERT_TRUE(app_list_service);
429 418
430 EXPECT_FALSE(app_list_service->IsAppListVisible()); 419 EXPECT_FALSE(app_list_service->IsAppListVisible());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 app_host()->OnTaskDestroyed(2); 532 app_host()->OnTaskDestroyed(2);
544 EXPECT_EQ(delegate2, GetShelfItemDelegate(shelf_id2)); 533 EXPECT_EQ(delegate2, GetShelfItemDelegate(shelf_id2));
545 // Destroy task #2, this kills shelf group 2 534 // Destroy task #2, this kills shelf group 2
546 app_host()->OnTaskDestroyed(3); 535 app_host()->OnTaskDestroyed(3);
547 EXPECT_FALSE(GetShelfItemDelegate(shelf_id2)); 536 EXPECT_FALSE(GetShelfItemDelegate(shelf_id2));
548 537
549 // Disable ARC, this removes app and as result kills shelf group 3. 538 // Disable ARC, this removes app and as result kills shelf group 3.
550 arc::SetArcPlayStoreEnabledForProfile(profile(), false); 539 arc::SetArcPlayStoreEnabledForProfile(profile(), false);
551 EXPECT_FALSE(GetShelfItemDelegate(shelf_id3)); 540 EXPECT_FALSE(GetShelfItemDelegate(shelf_id3));
552 } 541 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698