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

Side by Side Diff: chrome/browser/ui/app_list/app_context_menu_unittest.cc

Issue 1756193008: Support uninstalling ARC app from Chrome launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 9 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 | « no previous file | chrome/browser/ui/app_list/arc/arc_app_context_menu.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 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 arc_test.app_instance()->RefreshAppList(); 350 arc_test.app_instance()->RefreshAppList();
351 arc_test.app_instance()->SendRefreshAppList(arc_test.fake_apps()); 351 arc_test.app_instance()->SendRefreshAppList(arc_test.fake_apps());
352 352
353 ArcAppItem item(profile(), nullptr, app_id, std::string(), true); 353 ArcAppItem item(profile(), nullptr, app_id, std::string(), true);
354 354
355 ui::MenuModel* menu = item.GetContextMenuModel(); 355 ui::MenuModel* menu = item.GetContextMenuModel();
356 ASSERT_NE(nullptr, menu); 356 ASSERT_NE(nullptr, menu);
357 357
358 ASSERT_EQ(3, menu->GetItemCount()); 358 ASSERT_EQ(3, menu->GetItemCount());
359 EXPECT_EQ(app_list::AppContextMenu::LAUNCH_NEW, menu->GetCommandIdAt(0)); 359 EXPECT_EQ(app_list::AppContextMenu::LAUNCH_NEW, menu->GetCommandIdAt(0));
360 EXPECT_EQ(true, menu->IsEnabledAt(0)); 360 EXPECT_TRUE(menu->IsEnabledAt(0));
361 EXPECT_EQ(false, menu->IsItemCheckedAt(0)); 361 EXPECT_FALSE(menu->IsItemCheckedAt(0));
362 EXPECT_EQ(-1, menu->GetCommandIdAt(1)); // separator 362 EXPECT_EQ(-1, menu->GetCommandIdAt(1)); // separator
363 EXPECT_EQ(app_list::AppContextMenu::TOGGLE_PIN, menu->GetCommandIdAt(2)); 363 EXPECT_EQ(app_list::AppContextMenu::TOGGLE_PIN, menu->GetCommandIdAt(2));
364 EXPECT_EQ(true, menu->IsEnabledAt(2)); 364 EXPECT_TRUE(menu->IsEnabledAt(2));
365 EXPECT_EQ(false, menu->IsItemCheckedAt(2)); 365 EXPECT_FALSE(menu->IsItemCheckedAt(2));
366 366
367 // Test activate request. 367 // Test activate request.
368 EXPECT_EQ(0u, arc_test.app_instance()->launch_requests().size()); 368 EXPECT_EQ(0u, arc_test.app_instance()->launch_requests().size());
369 369
370 menu->ActivatedAt(0); 370 menu->ActivatedAt(0);
371 arc_test.app_instance()->WaitForIncomingMethodCall(); 371 arc_test.app_instance()->WaitForIncomingMethodCall();
372 372
373 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests = 373 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests =
374 arc_test.app_instance()->launch_requests(); 374 arc_test.app_instance()->launch_requests();
375 ASSERT_EQ(1u, launch_requests.size()); 375 ASSERT_EQ(1u, launch_requests.size());
376 EXPECT_EQ(true, launch_requests[0]->IsForApp(app_info)); 376 EXPECT_TRUE(launch_requests[0]->IsForApp(app_info));
377 377
378 arc_test.app_instance()->RefreshAppList(); 378 arc_test.app_instance()->RefreshAppList();
379 arc_test.app_instance()->SendRefreshAppList(std::vector<arc::AppInfo>()); 379 arc_test.app_instance()->SendRefreshAppList(std::vector<arc::AppInfo>());
380 item.SetReady(false); 380 item.SetReady(false);
381 381
382 EXPECT_EQ(item.GetContextMenuModel(), menu); 382 EXPECT_EQ(item.GetContextMenuModel(), menu);
383 ASSERT_EQ(3, menu->GetItemCount()); 383 ASSERT_EQ(3, menu->GetItemCount());
384 EXPECT_EQ(app_list::AppContextMenu::LAUNCH_NEW, menu->GetCommandIdAt(0)); 384 EXPECT_EQ(app_list::AppContextMenu::LAUNCH_NEW, menu->GetCommandIdAt(0));
385 EXPECT_EQ(false, menu->IsEnabledAt(0)); 385 EXPECT_FALSE(menu->IsEnabledAt(0));
386 EXPECT_EQ(false, menu->IsItemCheckedAt(0)); 386 EXPECT_FALSE(menu->IsItemCheckedAt(0));
387 EXPECT_EQ(-1, menu->GetCommandIdAt(1)); // separator 387 EXPECT_EQ(-1, menu->GetCommandIdAt(1)); // separator
388 EXPECT_EQ(app_list::AppContextMenu::TOGGLE_PIN, menu->GetCommandIdAt(2)); 388 EXPECT_EQ(app_list::AppContextMenu::TOGGLE_PIN, menu->GetCommandIdAt(2));
389 EXPECT_EQ(true, menu->IsEnabledAt(2)); 389 EXPECT_TRUE(menu->IsEnabledAt(2));
390 EXPECT_EQ(false, menu->IsItemCheckedAt(2)); 390 EXPECT_FALSE(menu->IsItemCheckedAt(2));
391 }
392
393 TEST_F(AppContextMenuTest, ArcMenuStickyItem) {
394 ArcAppTest arc_test;
395 arc_test.SetUp(profile());
396 arc_test.bridge_service()->SetReady();
397
398 arc_test.app_instance()->RefreshAppList();
399 arc_test.app_instance()->SendRefreshAppList(arc_test.fake_apps());
400
401 {
402 // Verify menu of store
403 const arc::AppInfo& store_info = arc_test.fake_apps()[0];
404 const std::string store_id = ArcAppTest::GetAppId(store_info);
405 controller()->SetAppPinnable(store_id,
406 AppListControllerDelegate::PIN_EDITABLE);
407 ArcAppItem item(profile(), nullptr, store_id, std::string(), true);
408 ui::MenuModel* menu = item.GetContextMenuModel();
409 ASSERT_NE(nullptr, menu);
410
411 ASSERT_EQ(3, menu->GetItemCount());
412 EXPECT_EQ(app_list::AppContextMenu::LAUNCH_NEW, menu->GetCommandIdAt(0));
413 EXPECT_TRUE(menu->IsEnabledAt(0));
414 EXPECT_FALSE(menu->IsItemCheckedAt(0));
415 EXPECT_EQ(-1, menu->GetCommandIdAt(1)); // separator
416 EXPECT_EQ(app_list::AppContextMenu::TOGGLE_PIN, menu->GetCommandIdAt(2));
417 EXPECT_TRUE(menu->IsEnabledAt(2));
418 EXPECT_FALSE(menu->IsItemCheckedAt(2));
419 // No "uninstall" entry.
420 }
421
422 {
423 // Verify normal app menu
424 const arc::AppInfo& app_info = arc_test.fake_apps()[1];
425 const std::string app_id = ArcAppTest::GetAppId(app_info);
426 controller()->SetAppPinnable(app_id,
427 AppListControllerDelegate::PIN_EDITABLE);
428 ArcAppItem item(profile(), nullptr, app_id, std::string(), true);
429 ui::MenuModel* menu = item.GetContextMenuModel();
430 ASSERT_NE(nullptr, menu);
431
432 ASSERT_EQ(5, menu->GetItemCount());
433 EXPECT_EQ(app_list::AppContextMenu::LAUNCH_NEW, menu->GetCommandIdAt(0));
434 EXPECT_TRUE(menu->IsEnabledAt(0));
435 EXPECT_FALSE(menu->IsItemCheckedAt(0));
436 EXPECT_EQ(-1, menu->GetCommandIdAt(1)); // separator
437 EXPECT_EQ(app_list::AppContextMenu::TOGGLE_PIN, menu->GetCommandIdAt(2));
438 EXPECT_TRUE(menu->IsEnabledAt(2));
439 EXPECT_FALSE(menu->IsItemCheckedAt(2));
440 EXPECT_EQ(-1, menu->GetCommandIdAt(3)); // separator
441 EXPECT_EQ(app_list::AppContextMenu::UNINSTALL, menu->GetCommandIdAt(4));
442 EXPECT_TRUE(menu->IsEnabledAt(4));
443 EXPECT_FALSE(menu->IsItemCheckedAt(4));
444 }
391 } 445 }
392 #endif 446 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/arc/arc_app_context_menu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698