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

Side by Side Diff: chrome/browser/extensions/extension_toolbar_model_unittest.cc

Issue 731353002: [Extensions Toolbar] Notify observers of extensions re-added after a pref change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Marijn's Created 6 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
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 SetReady(); 1304 SetReady();
1305 // Run tasks posted to TestExtensionSystem. 1305 // Run tasks posted to TestExtensionSystem.
1306 base::RunLoop().RunUntilIdle(); 1306 base::RunLoop().RunUntilIdle();
1307 1307
1308 // We should still have no insertions, but should have an initialized count. 1308 // We should still have no insertions, but should have an initialized count.
1309 EXPECT_TRUE(toolbar_model->extensions_initialized()); 1309 EXPECT_TRUE(toolbar_model->extensions_initialized());
1310 EXPECT_EQ(0u, model_observer.inserted_count()); 1310 EXPECT_EQ(0u, model_observer.inserted_count());
1311 EXPECT_EQ(1u, model_observer.initialized_count()); 1311 EXPECT_EQ(1u, model_observer.initialized_count());
1312 } 1312 }
1313 1313
1314 // Check that the toolbar model correctly clears and reorders when it detects
1315 // a preference change.
1316 TEST_F(ExtensionToolbarModelUnitTest, ToolbarModelPrefChange) {
1317 Init();
1318
1319 ASSERT_TRUE(AddBrowserActionExtensions());
1320
1321 // We should start in the basic A B C order.
1322 ASSERT_TRUE(browser_action_a());
1323 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0));
1324 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1));
1325 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(2));
1326 // Record the difference between the inserted and removed counts. The actual
1327 // value of the counts is not important, but we need to be sure that if we
1328 // call to remove any, we also add them back.
1329 size_t inserted_and_removed_difference =
1330 observer()->inserted_count() - observer()->removed_count();
1331
1332 // Assign a new order, B C A, and write it in the prefs.
1333 ExtensionIdList new_order;
1334 new_order.push_back(browser_action_b()->id());
1335 new_order.push_back(browser_action_c()->id());
1336 new_order.push_back(browser_action_a()->id());
1337 ExtensionPrefs::Get(profile())->SetToolbarOrder(new_order);
1338
1339 // Ensure everything has time to run.
1340 base::RunLoop().RunUntilIdle();
1341
1342 // The new order should be reflected in the model.
1343 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(0));
1344 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(1));
1345 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(2));
1346 EXPECT_EQ(inserted_and_removed_difference,
1347 observer()->inserted_count() - observer()->removed_count());
1348 }
1349
1314 } // namespace extensions 1350 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698