| OLD | NEW | 
|---|
| 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/macros.h" | 5 #include "base/macros.h" | 
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" | 
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" | 
| 8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" | 
| 10 #include "chrome/browser/extensions/extension_service_test_base.h" | 10 #include "chrome/browser/extensions/extension_service_test_base.h" | 
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 286   EXPECT_EQ(NULL, GetExtensionAtIndex(0u)); | 286   EXPECT_EQ(NULL, GetExtensionAtIndex(0u)); | 
| 287 | 287 | 
| 288   // Load an extension with a browser action. | 288   // Load an extension with a browser action. | 
| 289   scoped_refptr<const Extension> extension2 = | 289   scoped_refptr<const Extension> extension2 = | 
| 290       GetActionExtension("browser_action", manifest_keys::kBrowserAction); | 290       GetActionExtension("browser_action", manifest_keys::kBrowserAction); | 
| 291   ASSERT_TRUE(AddExtension(extension2)); | 291   ASSERT_TRUE(AddExtension(extension2)); | 
| 292 | 292 | 
| 293   // We should now find our extension in the model. | 293   // We should now find our extension in the model. | 
| 294   EXPECT_EQ(1u, observer()->inserted_count()); | 294   EXPECT_EQ(1u, observer()->inserted_count()); | 
| 295   EXPECT_EQ(1u, num_toolbar_items()); | 295   EXPECT_EQ(1u, num_toolbar_items()); | 
| 296   EXPECT_EQ(extension2, GetExtensionAtIndex(0u)); | 296   EXPECT_EQ(extension2.get(), GetExtensionAtIndex(0u)); | 
| 297 | 297 | 
| 298   // Should be a no-op, but still fires the events. | 298   // Should be a no-op, but still fires the events. | 
| 299   toolbar_model()->MoveExtensionIcon(extension2.get(), 0); | 299   toolbar_model()->MoveExtensionIcon(extension2.get(), 0); | 
| 300   EXPECT_EQ(1u, observer()->moved_count()); | 300   EXPECT_EQ(1u, observer()->moved_count()); | 
| 301   EXPECT_EQ(1u, num_toolbar_items()); | 301   EXPECT_EQ(1u, num_toolbar_items()); | 
| 302   EXPECT_EQ(extension2, GetExtensionAtIndex(0u)); | 302   EXPECT_EQ(extension2.get(), GetExtensionAtIndex(0u)); | 
| 303 | 303 | 
| 304   // Remove the extension and verify. | 304   // Remove the extension and verify. | 
| 305   ASSERT_TRUE(RemoveExtension(extension2)); | 305   ASSERT_TRUE(RemoveExtension(extension2)); | 
| 306   EXPECT_EQ(1u, observer()->removed_count()); | 306   EXPECT_EQ(1u, observer()->removed_count()); | 
| 307   EXPECT_EQ(0u, num_toolbar_items()); | 307   EXPECT_EQ(0u, num_toolbar_items()); | 
| 308   EXPECT_EQ(NULL, GetExtensionAtIndex(0u)); | 308   EXPECT_EQ(NULL, GetExtensionAtIndex(0u)); | 
| 309 } | 309 } | 
| 310 | 310 | 
| 311 // Test various different reorderings, removals, and reinsertions. | 311 // Test various different reorderings, removals, and reinsertions. | 
| 312 TEST_F(ExtensionToolbarModelUnitTest, ExtensionToolbarReorderAndReinsert) { | 312 TEST_F(ExtensionToolbarModelUnitTest, ExtensionToolbarReorderAndReinsert) { | 
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 811   ExtensionActionAPI::SetBrowserActionVisibility( | 811   ExtensionActionAPI::SetBrowserActionVisibility( | 
| 812       prefs, extension_b->id(), true); | 812       prefs, extension_b->id(), true); | 
| 813   EXPECT_EQ(3u, num_toolbar_items()); | 813   EXPECT_EQ(3u, num_toolbar_items()); | 
| 814   EXPECT_EQ(-1, toolbar_model()->GetVisibleIconCount());  // -1 = 'all' | 814   EXPECT_EQ(-1, toolbar_model()->GetVisibleIconCount());  // -1 = 'all' | 
| 815   EXPECT_EQ(extension_c, GetExtensionAtIndex(0u)); | 815   EXPECT_EQ(extension_c, GetExtensionAtIndex(0u)); | 
| 816   EXPECT_EQ(extension_a, GetExtensionAtIndex(1u)); | 816   EXPECT_EQ(extension_a, GetExtensionAtIndex(1u)); | 
| 817   EXPECT_EQ(extension_b, GetExtensionAtIndex(2u)); | 817   EXPECT_EQ(extension_b, GetExtensionAtIndex(2u)); | 
| 818 } | 818 } | 
| 819 | 819 | 
| 820 }  // namespace extensions | 820 }  // namespace extensions | 
| OLD | NEW | 
|---|