| 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/common/extensions/features/feature_channel.h" | |
| 7 #include "chrome/common/extensions/manifest_handlers/automation.h" | 6 #include "chrome/common/extensions/manifest_handlers/automation.h" |
| 8 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" | 7 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 9 #include "chrome/grit/generated_resources.h" | 8 #include "chrome/grit/generated_resources.h" |
| 10 #include "extensions/common/error_utils.h" | 9 #include "extensions/common/error_utils.h" |
| 11 #include "extensions/common/manifest_constants.h" | 10 #include "extensions/common/manifest_constants.h" |
| 12 #include "extensions/common/permissions/permissions_data.h" | 11 #include "extensions/common/permissions/permissions_data.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 15 | 14 |
| 16 namespace extensions { | 15 namespace extensions { |
| 17 | 16 |
| 18 class AutomationManifestTest : public ChromeManifestTest { | 17 class AutomationManifestTest : public ExtensionManifestTest { |
| 19 public: | 18 public: |
| 20 AutomationManifestTest() : channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {} | 19 AutomationManifestTest() : channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {} |
| 21 | 20 |
| 22 protected: | 21 protected: |
| 23 AutomationInfo* GetAutomationInfo(scoped_refptr<Extension> extension) { | 22 AutomationInfo* GetAutomationInfo(scoped_refptr<Extension> extension) { |
| 24 return static_cast<AutomationInfo*>( | 23 return static_cast<AutomationInfo*>( |
| 25 extension->GetManifestData(manifest_keys::kAutomation)); | 24 extension->GetManifestData(manifest_keys::kAutomation)); |
| 26 } | 25 } |
| 27 | 26 |
| 28 private: | 27 private: |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 ASSERT_TRUE(info); | 149 ASSERT_TRUE(info); |
| 151 | 150 |
| 152 EXPECT_FALSE(info->desktop); | 151 EXPECT_FALSE(info->desktop); |
| 153 EXPECT_FALSE(info->interact); | 152 EXPECT_FALSE(info->interact); |
| 154 EXPECT_TRUE(info->matches.is_empty()); | 153 EXPECT_TRUE(info->matches.is_empty()); |
| 155 } | 154 } |
| 156 | 155 |
| 157 TEST_F(AutomationManifestTest, NoValidMatches) { | 156 TEST_F(AutomationManifestTest, NoValidMatches) { |
| 158 std::string error; | 157 std::string error; |
| 159 scoped_refptr<Extension> extension = | 158 scoped_refptr<Extension> extension = |
| 160 LoadExtension(ManifestData("automation_no_valid_matches.json"), &error); | 159 LoadExtension(Manifest("automation_no_valid_matches.json"), &error); |
| 161 ASSERT_TRUE(extension.get()); | 160 ASSERT_TRUE(extension.get()); |
| 162 EXPECT_EQ("", error); | 161 EXPECT_EQ("", error); |
| 163 EXPECT_EQ(2u, extension->install_warnings().size()); | 162 EXPECT_EQ(2u, extension->install_warnings().size()); |
| 164 EXPECT_EQ(ErrorUtils::FormatErrorMessage( | 163 EXPECT_EQ(ErrorUtils::FormatErrorMessage( |
| 165 automation_errors::kErrorInvalidMatch, | 164 automation_errors::kErrorInvalidMatch, |
| 166 "www.badpattern.com", | 165 "www.badpattern.com", |
| 167 URLPattern::GetParseResultString( | 166 URLPattern::GetParseResultString( |
| 168 URLPattern::PARSE_ERROR_MISSING_SCHEME_SEPARATOR)), | 167 URLPattern::PARSE_ERROR_MISSING_SCHEME_SEPARATOR)), |
| 169 extension->install_warnings()[0].message); | 168 extension->install_warnings()[0].message); |
| 170 EXPECT_EQ(automation_errors::kErrorNoMatchesProvided, | 169 EXPECT_EQ(automation_errors::kErrorNoMatchesProvided, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 271 |
| 273 const AutomationInfo* info = AutomationInfo::Get(extension.get()); | 272 const AutomationInfo* info = AutomationInfo::Get(extension.get()); |
| 274 ASSERT_TRUE(info); | 273 ASSERT_TRUE(info); |
| 275 | 274 |
| 276 EXPECT_TRUE(info->desktop); | 275 EXPECT_TRUE(info->desktop); |
| 277 EXPECT_TRUE(info->interact); | 276 EXPECT_TRUE(info->interact); |
| 278 EXPECT_TRUE(info->matches.is_empty()); | 277 EXPECT_TRUE(info->matches.is_empty()); |
| 279 } | 278 } |
| 280 | 279 |
| 281 } // namespace extensions | 280 } // namespace extensions |
| OLD | NEW |