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

Side by Side Diff: extensions/common/extension_resource_unittest.cc

Issue 13198003: Remove the chrome include in extensions\DEPS by creating a test data directory for extensions. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « extensions/common/extension_paths.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "chrome/common/chrome_paths.h"
11 #include "extensions/common/constants.h" 10 #include "extensions/common/constants.h"
11 #include "extensions/common/extension_paths.h"
12 #include "extensions/common/extension_resource.h" 12 #include "extensions/common/extension_resource.h"
13 #include "extensions/common/id_util.h" 13 #include "extensions/common/id_util.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 16
17 namespace extensions { 17 namespace extensions {
18 18
19 TEST(ExtensionResourceTest, CreateEmptyResource) { 19 TEST(ExtensionResourceTest, CreateEmptyResource) {
20 ExtensionResource resource; 20 ExtensionResource resource;
21 21
22 EXPECT_TRUE(resource.extension_root().empty()); 22 EXPECT_TRUE(resource.extension_root().empty());
23 EXPECT_TRUE(resource.relative_path().empty()); 23 EXPECT_TRUE(resource.relative_path().empty());
24 EXPECT_TRUE(resource.GetFilePath().empty()); 24 EXPECT_TRUE(resource.GetFilePath().empty());
25 } 25 }
26 26
27 const base::FilePath::StringType ToLower( 27 const base::FilePath::StringType ToLower(
28 const base::FilePath::StringType& in_str) { 28 const base::FilePath::StringType& in_str) {
29 base::FilePath::StringType str(in_str); 29 base::FilePath::StringType str(in_str);
30 std::transform(str.begin(), str.end(), str.begin(), tolower); 30 std::transform(str.begin(), str.end(), str.begin(), tolower);
31 return str; 31 return str;
32 } 32 }
33 33
34 TEST(ExtensionResourceTest, CreateWithMissingResourceOnDisk) { 34 TEST(ExtensionResourceTest, CreateWithMissingResourceOnDisk) {
35 base::FilePath root_path; 35 base::FilePath root_path;
36 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &root_path)); 36 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &root_path));
37 base::FilePath relative_path; 37 base::FilePath relative_path;
38 relative_path = relative_path.AppendASCII("cira.js"); 38 relative_path = relative_path.AppendASCII("cira.js");
39 std::string extension_id = id_util::GenerateId("test"); 39 std::string extension_id = id_util::GenerateId("test");
40 ExtensionResource resource(extension_id, root_path, relative_path); 40 ExtensionResource resource(extension_id, root_path, relative_path);
41 41
42 // The path doesn't exist on disk, we will be returned an empty path. 42 // The path doesn't exist on disk, we will be returned an empty path.
43 EXPECT_EQ(root_path.value(), resource.extension_root().value()); 43 EXPECT_EQ(root_path.value(), resource.extension_root().value());
44 EXPECT_EQ(relative_path.value(), resource.relative_path().value()); 44 EXPECT_EQ(relative_path.value(), resource.relative_path().value());
45 EXPECT_TRUE(resource.GetFilePath().empty()); 45 EXPECT_TRUE(resource.GetFilePath().empty());
46 } 46 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ASSERT_TRUE(file_util::AbsolutePath(&expected_path)); 154 ASSERT_TRUE(file_util::AbsolutePath(&expected_path));
155 155
156 EXPECT_EQ(ToLower(expected_path.value()), ToLower(resolved_path.value())); 156 EXPECT_EQ(ToLower(expected_path.value()), ToLower(resolved_path.value()));
157 EXPECT_EQ(ToLower(temp.path().value()), 157 EXPECT_EQ(ToLower(temp.path().value()),
158 ToLower(resource.extension_root().value())); 158 ToLower(resource.extension_root().value()));
159 EXPECT_EQ(ToLower(base::FilePath().AppendASCII(filename).value()), 159 EXPECT_EQ(ToLower(base::FilePath().AppendASCII(filename).value()),
160 ToLower(resource.relative_path().value())); 160 ToLower(resource.relative_path().value()));
161 } 161 }
162 162
163 } // namespace extensions 163 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/extension_paths.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698