| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 return ExtensionBuilder().SetManifest(manifest.Pass()) | 75 return ExtensionBuilder().SetManifest(manifest.Pass()) |
| 76 .SetID(crx_file::id_util::GenerateId(name)) | 76 .SetID(crx_file::id_util::GenerateId(name)) |
| 77 .Build(); | 77 .Build(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // A simple observer that tracks the number of times certain events occur. | 80 // A simple observer that tracks the number of times certain events occur. |
| 81 class ExtensionToolbarModelTestObserver | 81 class ExtensionToolbarModelTestObserver |
| 82 : public ExtensionToolbarModel::Observer { | 82 : public ExtensionToolbarModel::Observer { |
| 83 public: | 83 public: |
| 84 explicit ExtensionToolbarModelTestObserver(ExtensionToolbarModel* model); | 84 explicit ExtensionToolbarModelTestObserver(ExtensionToolbarModel* model); |
| 85 virtual ~ExtensionToolbarModelTestObserver(); | 85 ~ExtensionToolbarModelTestObserver() override; |
| 86 | 86 |
| 87 size_t inserted_count() const { return inserted_count_; } | 87 size_t inserted_count() const { return inserted_count_; } |
| 88 size_t removed_count() const { return removed_count_; } | 88 size_t removed_count() const { return removed_count_; } |
| 89 size_t moved_count() const { return moved_count_; } | 89 size_t moved_count() const { return moved_count_; } |
| 90 int highlight_mode_count() const { return highlight_mode_count_; } | 90 int highlight_mode_count() const { return highlight_mode_count_; } |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 // ExtensionToolbarModel::Observer: | 93 // ExtensionToolbarModel::Observer: |
| 94 virtual void ToolbarExtensionAdded(const Extension* extension, | 94 void ToolbarExtensionAdded(const Extension* extension, int index) override { |
| 95 int index) override { | |
| 96 ++inserted_count_; | 95 ++inserted_count_; |
| 97 } | 96 } |
| 98 | 97 |
| 99 virtual void ToolbarExtensionRemoved(const Extension* extension) override { | 98 void ToolbarExtensionRemoved(const Extension* extension) override { |
| 100 ++removed_count_; | 99 ++removed_count_; |
| 101 } | 100 } |
| 102 | 101 |
| 103 virtual void ToolbarExtensionMoved(const Extension* extension, | 102 void ToolbarExtensionMoved(const Extension* extension, int index) override { |
| 104 int index) override { | |
| 105 ++moved_count_; | 103 ++moved_count_; |
| 106 } | 104 } |
| 107 | 105 |
| 108 virtual void ToolbarExtensionUpdated(const Extension* extension) override { | 106 void ToolbarExtensionUpdated(const Extension* extension) override {} |
| 109 } | |
| 110 | 107 |
| 111 virtual bool ShowExtensionActionPopup(const Extension* extension, | 108 bool ShowExtensionActionPopup(const Extension* extension, |
| 112 bool grant_active_tab) override { | 109 bool grant_active_tab) override { |
| 113 return false; | 110 return false; |
| 114 } | 111 } |
| 115 | 112 |
| 116 virtual void ToolbarVisibleCountChanged() override { | 113 void ToolbarVisibleCountChanged() override {} |
| 117 } | |
| 118 | 114 |
| 119 virtual void ToolbarHighlightModeChanged(bool is_highlighting) override { | 115 void ToolbarHighlightModeChanged(bool is_highlighting) override { |
| 120 // Add one if highlighting, subtract one if not. | 116 // Add one if highlighting, subtract one if not. |
| 121 highlight_mode_count_ += is_highlighting ? 1 : -1; | 117 highlight_mode_count_ += is_highlighting ? 1 : -1; |
| 122 } | 118 } |
| 123 | 119 |
| 124 virtual Browser* GetBrowser() override { | 120 Browser* GetBrowser() override { return NULL; } |
| 125 return NULL; | |
| 126 } | |
| 127 | 121 |
| 128 ExtensionToolbarModel* model_; | 122 ExtensionToolbarModel* model_; |
| 129 | 123 |
| 130 size_t inserted_count_; | 124 size_t inserted_count_; |
| 131 size_t removed_count_; | 125 size_t removed_count_; |
| 132 size_t moved_count_; | 126 size_t moved_count_; |
| 133 // Int because it could become negative (if something goes wrong). | 127 // Int because it could become negative (if something goes wrong). |
| 134 int highlight_mode_count_; | 128 int highlight_mode_count_; |
| 135 }; | 129 }; |
| 136 | 130 |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 ExtensionActionAPI::SetBrowserActionVisibility( | 912 ExtensionActionAPI::SetBrowserActionVisibility( |
| 919 prefs, extension_b->id(), true); | 913 prefs, extension_b->id(), true); |
| 920 EXPECT_EQ(3u, num_toolbar_items()); | 914 EXPECT_EQ(3u, num_toolbar_items()); |
| 921 EXPECT_EQ(-1, toolbar_model()->GetVisibleIconCount()); // -1 = 'all' | 915 EXPECT_EQ(-1, toolbar_model()->GetVisibleIconCount()); // -1 = 'all' |
| 922 EXPECT_EQ(extension_c, GetExtensionAtIndex(0u)); | 916 EXPECT_EQ(extension_c, GetExtensionAtIndex(0u)); |
| 923 EXPECT_EQ(extension_a, GetExtensionAtIndex(1u)); | 917 EXPECT_EQ(extension_a, GetExtensionAtIndex(1u)); |
| 924 EXPECT_EQ(extension_b, GetExtensionAtIndex(2u)); | 918 EXPECT_EQ(extension_b, GetExtensionAtIndex(2u)); |
| 925 } | 919 } |
| 926 | 920 |
| 927 } // namespace extensions | 921 } // namespace extensions |
| OLD | NEW |