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

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

Issue 562273006: Move the last extensions/common unit tests to extensions_unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@manifest2
Patch Set: (file-tests) rebase 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h"
7 #include "base/path_service.h"
6 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "chrome/common/chrome_paths.h"
7 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" 10 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
8 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" 11 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
9 #include "extensions/common/error_utils.h" 12 #include "extensions/common/error_utils.h"
10 #include "extensions/common/extension.h" 13 #include "extensions/common/extension.h"
14 #include "extensions/common/file_util.h"
11 #include "extensions/common/manifest_constants.h" 15 #include "extensions/common/manifest_constants.h"
12 #include "extensions/common/switches.h" 16 #include "extensions/common/switches.h"
13 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
14 18
15 namespace extensions { 19 namespace extensions {
16 20
17 namespace errors = manifest_errors; 21 namespace errors = manifest_errors;
18 22
19 class ContentScriptsManifestTest : public ChromeManifestTest { 23 class ContentScriptsManifestTest : public ChromeManifestTest {
20 }; 24 };
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ContentScriptsInfo::GetContentScripts(extension1.get()); 80 ContentScriptsInfo::GetContentScripts(extension1.get());
77 ASSERT_EQ(1u, user_scripts1.size()); 81 ASSERT_EQ(1u, user_scripts1.size());
78 int id = user_scripts1[0].id(); 82 int id = user_scripts1[0].id();
79 const UserScriptList& user_scripts2 = 83 const UserScriptList& user_scripts2 =
80 ContentScriptsInfo::GetContentScripts(extension2.get()); 84 ContentScriptsInfo::GetContentScripts(extension2.get());
81 ASSERT_EQ(1u, user_scripts2.size()); 85 ASSERT_EQ(1u, user_scripts2.size());
82 // The id of the content script should be one higher than the previous. 86 // The id of the content script should be one higher than the previous.
83 EXPECT_EQ(id + 1, user_scripts2[0].id()); 87 EXPECT_EQ(id + 1, user_scripts2[0].id());
84 } 88 }
85 89
90 TEST_F(ContentScriptsManifestTest, FailLoadingNonUTF8Scripts) {
91 base::FilePath install_dir;
92 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir));
93 install_dir = install_dir.AppendASCII("extensions")
94 .AppendASCII("bad")
95 .AppendASCII("bad_encoding");
96
97 std::string error;
98 scoped_refptr<Extension> extension(file_util::LoadExtension(
99 install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
100 ASSERT_TRUE(extension.get() == NULL);
101 ASSERT_STREQ(
102 "Could not load file 'bad_encoding.js' for content script. "
103 "It isn't UTF-8 encoded.",
104 error.c_str());
105 }
106
86 } // namespace extensions 107 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698