OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const char* filename = "res.ico"; | 51 const char* filename = "res.ico"; |
52 FilePath root_resource = temp.path().AppendASCII(filename); | 52 FilePath root_resource = temp.path().AppendASCII(filename); |
53 std::string data = "some foo"; | 53 std::string data = "some foo"; |
54 ASSERT_TRUE(file_util::WriteFile(root_resource, data.c_str(), data.length())); | 54 ASSERT_TRUE(file_util::WriteFile(root_resource, data.c_str(), data.length())); |
55 | 55 |
56 // Create l10n resources (for current locale and its parents). | 56 // Create l10n resources (for current locale and its parents). |
57 FilePath l10n_path = temp.path().Append(Extension::kLocaleFolder); | 57 FilePath l10n_path = temp.path().Append(Extension::kLocaleFolder); |
58 ASSERT_TRUE(file_util::CreateDirectory(l10n_path)); | 58 ASSERT_TRUE(file_util::CreateDirectory(l10n_path)); |
59 | 59 |
60 std::vector<std::string> locales; | 60 std::vector<std::string> locales; |
61 extension_l10n_util::GetParentLocales(l10n_util::GetApplicationLocale(""), | 61 l10n_util::GetParentLocales(l10n_util::GetApplicationLocale(""), &locales); |
62 &locales); | |
63 ASSERT_FALSE(locales.empty()); | 62 ASSERT_FALSE(locales.empty()); |
64 for (size_t i = 0; i < locales.size(); i++) { | 63 for (size_t i = 0; i < locales.size(); i++) { |
65 FilePath make_path; | 64 FilePath make_path; |
66 make_path = l10n_path.AppendASCII(locales[i]); | 65 make_path = l10n_path.AppendASCII(locales[i]); |
67 ASSERT_TRUE(file_util::CreateDirectory(make_path)); | 66 ASSERT_TRUE(file_util::CreateDirectory(make_path)); |
68 ASSERT_TRUE(file_util::WriteFile(make_path.AppendASCII(filename), | 67 ASSERT_TRUE(file_util::WriteFile(make_path.AppendASCII(filename), |
69 data.c_str(), data.length())); | 68 data.c_str(), data.length())); |
70 } | 69 } |
71 | 70 |
72 FilePath path; | 71 FilePath path; |
73 std::string extension_id; | 72 std::string extension_id; |
74 Extension::GenerateId("test", &extension_id); | 73 Extension::GenerateId("test", &extension_id); |
75 ExtensionResource resource(extension_id, temp.path(), | 74 ExtensionResource resource(extension_id, temp.path(), |
76 FilePath().AppendASCII(filename)); | 75 FilePath().AppendASCII(filename)); |
77 FilePath resolved_path = resource.GetFilePath(); | 76 FilePath resolved_path = resource.GetFilePath(); |
78 | 77 |
79 FilePath expected_path; | 78 FilePath expected_path; |
80 // Expect default path only, since fallback logic is disabled. | 79 // Expect default path only, since fallback logic is disabled. |
81 // See http://crbug.com/27359. | 80 // See http://crbug.com/27359. |
82 expected_path = root_resource; | 81 expected_path = root_resource; |
83 ASSERT_TRUE(file_util::AbsolutePath(&expected_path)); | 82 ASSERT_TRUE(file_util::AbsolutePath(&expected_path)); |
84 | 83 |
85 EXPECT_EQ(ToLower(expected_path.value()), ToLower(resolved_path.value())); | 84 EXPECT_EQ(ToLower(expected_path.value()), ToLower(resolved_path.value())); |
86 EXPECT_EQ(ToLower(temp.path().value()), | 85 EXPECT_EQ(ToLower(temp.path().value()), |
87 ToLower(resource.extension_root().value())); | 86 ToLower(resource.extension_root().value())); |
88 EXPECT_EQ(ToLower(FilePath().AppendASCII(filename).value()), | 87 EXPECT_EQ(ToLower(FilePath().AppendASCII(filename).value()), |
89 ToLower(resource.relative_path().value())); | 88 ToLower(resource.relative_path().value())); |
90 } | 89 } |
OLD | NEW |