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

Side by Side Diff: chrome/common/extensions/manifest_handlers/automation_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698