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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc

Issue 2450633004: Make ToolbarActionsModel ignore calls to AddComponentAction() before initialization (Closed)
Patch Set: Move the initialization check to within AddComponentAction(); add a unit test Created 4 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/toolbar/toolbar_actions_model.h" 5 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 base::Bind(&base::DoNothing), 1451 base::Bind(&base::DoNothing),
1452 nullptr); 1452 nullptr);
1453 base::RunLoop().RunUntilIdle(); 1453 base::RunLoop().RunUntilIdle();
1454 1454
1455 EXPECT_EQ(2u, num_toolbar_items()); 1455 EXPECT_EQ(2u, num_toolbar_items());
1456 EXPECT_EQ(1u, toolbar_model()->visible_icon_count()); 1456 EXPECT_EQ(1u, toolbar_model()->visible_icon_count());
1457 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(0u)); 1457 EXPECT_EQ(browser_action_a()->id(), GetActionIdAtIndex(0u));
1458 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(1u)); 1458 EXPECT_EQ(browser_action_c()->id(), GetActionIdAtIndex(1u));
1459 } 1459 }
1460 1460
1461 TEST_F(ToolbarActionsModelUnitTest, AddComponentActionBeforeInitialization) {
1462 InitializeEmptyExtensionService();
1463 ToolbarActionsModel* toolbar_model = extensions::extension_action_test_util::
1464 CreateToolbarModelForProfileWithoutWaitingForReady(profile());
1465 ASSERT_FALSE(toolbar_model->actions_initialized());
1466
1467 // AddComponentAction() should be a no-op if actions_initialized() is false.
1468 toolbar_model->AddComponentAction(component_action_id());
Devlin 2016/10/26 16:41:56 While this will trigger the crash, I think this wo
takumif 2016/10/26 18:42:06 I believe this is close to what is happening. MRAC
1469 EXPECT_EQ(0u, toolbar_model->toolbar_items().size());
1470 EXPECT_FALSE(toolbar_model->HasComponentAction(component_action_id()));
1471 }
1472
1461 TEST_F(ToolbarActionsModelUnitTest, 1473 TEST_F(ToolbarActionsModelUnitTest,
1462 NoMigrationToComponentActionWithoutExtension) { 1474 NoMigrationToComponentActionWithoutExtension) {
1463 extensions::FeatureSwitch::ScopedOverride enable_redesign( 1475 extensions::FeatureSwitch::ScopedOverride enable_redesign(
1464 extensions::FeatureSwitch::extension_action_redesign(), true); 1476 extensions::FeatureSwitch::extension_action_redesign(), true);
1465 InitForMigrationTest(MigrationStatus::FEATURE_ENABLED_NO_EXTENSION); 1477 InitForMigrationTest(MigrationStatus::FEATURE_ENABLED_NO_EXTENSION);
1466 1478
1467 EXPECT_EQ(0u, num_toolbar_items()); 1479 EXPECT_EQ(0u, num_toolbar_items());
1468 } 1480 }
1469 1481
1470 TEST_F(ToolbarActionsModelUnitTest, MigrationFromExtensionToComponentAction) { 1482 TEST_F(ToolbarActionsModelUnitTest, MigrationFromExtensionToComponentAction) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 } 1519 }
1508 1520
1509 TEST_F(ToolbarActionsModelUnitTest, 1521 TEST_F(ToolbarActionsModelUnitTest,
1510 MigrationToExtensionWithoutExtensionActionRedesign) { 1522 MigrationToExtensionWithoutExtensionActionRedesign) {
1511 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE); 1523 InitForMigrationTest(MigrationStatus::FEATURE_DISABLED_WITH_PREF_TRUE);
1512 1524
1513 // Initialization re-enables the extension. 1525 // Initialization re-enables the extension.
1514 EXPECT_EQ(1u, num_toolbar_items()); 1526 EXPECT_EQ(1u, num_toolbar_items());
1515 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u)); 1527 EXPECT_EQ(browser_action_migrated()->id(), GetActionIdAtIndex(0u));
1516 } 1528 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698