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

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: 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
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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_EQ(false, menu->IsEnabledAt(0));
386 EXPECT_EQ(false, menu->IsItemCheckedAt(0)); 386 EXPECT_EQ(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_EQ(true, menu->IsEnabledAt(2));
390 EXPECT_EQ(false, menu->IsItemCheckedAt(2)); 390 EXPECT_EQ(false, menu->IsItemCheckedAt(2));
391 } 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));
khmel 2016/03/08 00:09:54 nit: I know you followed code style in this file,
victorhsieh0 2016/03/08 00:33:07 Done.
413 EXPECT_EQ(true, menu->IsEnabledAt(0));
414 EXPECT_EQ(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_EQ(true, menu->IsEnabledAt(2));
418 EXPECT_EQ(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_EQ(true, menu->IsEnabledAt(0));
435 EXPECT_EQ(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_EQ(true, menu->IsEnabledAt(2));
439 EXPECT_EQ(false, menu->IsItemCheckedAt(2));
440 EXPECT_EQ(-1, menu->GetCommandIdAt(3)); // separator
441 EXPECT_EQ(app_list::AppContextMenu::UNINSTALL, menu->GetCommandIdAt(4));
442 EXPECT_EQ(true, menu->IsEnabledAt(4));
443 EXPECT_EQ(false, menu->IsItemCheckedAt(4));
444 }
445 }
392 #endif 446 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698