| 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 "chrome/browser/extensions/extension_action_manager.h" | 5 #include "chrome/browser/extensions/extension_action_manager.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_action.h" | 8 #include "chrome/browser/extensions/extension_action.h" |
| 9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 10 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 profile_(new TestingProfile) { | 68 profile_(new TestingProfile) { |
| 69 registry_ = ExtensionRegistry::Get(profile_.get()); | 69 registry_ = ExtensionRegistry::Get(profile_.get()); |
| 70 manager_ = ExtensionActionManager::Get(profile_.get()); | 70 manager_ = ExtensionActionManager::Get(profile_.get()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 scoped_refptr<Extension> ExtensionActionManagerTest::BuildExtension( | 73 scoped_refptr<Extension> ExtensionActionManagerTest::BuildExtension( |
| 74 DictionaryBuilder& extension_icons, | 74 DictionaryBuilder& extension_icons, |
| 75 DictionaryBuilder& action, | 75 DictionaryBuilder& action, |
| 76 const char* action_type) { | 76 const char* action_type) { |
| 77 std::string id = base::IntToString(curr_id_++); | 77 std::string id = base::IntToString(curr_id_++); |
| 78 scoped_refptr<Extension> extension = ExtensionBuilder() | 78 scoped_refptr<Extension> extension = |
| 79 .SetManifest(DictionaryBuilder().Set("version", "1") | 79 ExtensionBuilder() |
| 80 .Set("manifest_version", 2) | 80 .SetManifest( |
| 81 .Set("icons", extension_icons) | 81 DictionaryBuilder() |
| 82 .Set(action_type, action) | 82 .Set("version", "1") |
| 83 .Set("name", | 83 .Set("manifest_version", 2) |
| 84 std::string("Test Extension").append(id))) | 84 .Set("icons", extension_icons) |
| 85 .SetID(id) | 85 .Set(action_type, action) |
| 86 .Build(); | 86 .Set("name", std::string("Test Extension").append(id))) |
| 87 .SetLocation(Manifest::UNPACKED) |
| 88 .SetID(id) |
| 89 .Build(); |
| 87 registry_->AddEnabled(extension); | 90 registry_->AddEnabled(extension); |
| 88 return extension; | 91 return extension; |
| 89 } | 92 } |
| 90 | 93 |
| 91 bool ExtensionActionManagerTest::TitlesMatch(const Extension& extension, | 94 bool ExtensionActionManagerTest::TitlesMatch(const Extension& extension, |
| 92 const ExtensionAction& action) { | 95 const ExtensionAction& action) { |
| 93 return action.GetTitle(ExtensionAction::kDefaultTabId) == extension.name(); | 96 return action.GetTitle(ExtensionAction::kDefaultTabId) == extension.name(); |
| 94 } | 97 } |
| 95 | 98 |
| 96 bool ExtensionActionManagerTest::IconsMatch(const Extension& extension, | 99 bool ExtensionActionManagerTest::IconsMatch(const Extension& extension, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 manager()->GetBestFitAction(*extension.get(), ActionInfo::TYPE_BROWSER); | 220 manager()->GetBestFitAction(*extension.get(), ActionInfo::TYPE_BROWSER); |
| 218 | 221 |
| 219 // Now these values match because |extension| does not have page action | 222 // Now these values match because |extension| does not have page action |
| 220 // defaults. | 223 // defaults. |
| 221 ASSERT_TRUE(TitlesMatch(*extension.get(), *action)); | 224 ASSERT_TRUE(TitlesMatch(*extension.get(), *action)); |
| 222 ASSERT_TRUE(IconsMatch(*extension.get(), 48, *action, 38)); | 225 ASSERT_TRUE(IconsMatch(*extension.get(), 48, *action, 38)); |
| 223 } | 226 } |
| 224 | 227 |
| 225 } // namespace | 228 } // namespace |
| 226 } // namespace extensions | 229 } // namespace extensions |
| OLD | NEW |