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

Unified Diff: chrome/common/extensions/extension_resource_unittest.cc

Issue 256022: Loads local resources from current locale subtree if available, if not it fal... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/extension_resource.cc ('k') | chrome/common/extensions/extension_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_resource_unittest.cc
===================================================================
--- chrome/common/extensions/extension_resource_unittest.cc (revision 0)
+++ chrome/common/extensions/extension_resource_unittest.cc (revision 0)
@@ -0,0 +1,60 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "app/l10n_util.h"
+#include "base/file_util.h"
+#include "base/path_service.h"
+#include "base/scoped_temp_dir.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_resource.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(ExtensionResourceTest, CreateEmptyResource) {
+ ExtensionResource resource;
+
+ EXPECT_TRUE(resource.extension_root().empty());
+ EXPECT_TRUE(resource.relative_path().empty());
+ EXPECT_TRUE(resource.GetFilePath().empty());
+}
+
+TEST(ExtensionResourceTest, CreateWithMissingResourceOnDisk) {
+ FilePath path;
+ ExtensionResource resource(path.AppendASCII("foo"), path.AppendASCII("bar"));
+
+ EXPECT_TRUE(path.AppendASCII("foo") == resource.extension_root());
+ EXPECT_TRUE(path.AppendASCII("bar") == resource.relative_path());
+ EXPECT_TRUE(path.AppendASCII("foo").AppendASCII("bar") ==
+ resource.GetFilePath());
+ EXPECT_FALSE(resource.GetFilePath().empty());
+}
+
+TEST(ExtensionResourceTest, CreateWithBothResourcesOnDisk) {
+ ScopedTempDir temp;
+ ASSERT_TRUE(temp.CreateUniqueTempDir());
+
+ const char* filename = "res.ico";
+ FilePath root_resource = temp.path().AppendASCII(filename);
+ std::string data = "some foo";
+ ASSERT_TRUE(file_util::WriteFile(root_resource.AppendASCII(filename),
+ data.c_str(), data.length()));
+
+ FilePath l10n_path = temp.path().AppendASCII(Extension::kLocaleFolder);
+ ASSERT_TRUE(file_util::CreateDirectory(l10n_path));
+
+ static std::string current_locale = l10n_util::GetApplicationLocale(L"");
+ std::replace(current_locale.begin(), current_locale.end(), '-', '_');
+ l10n_path = l10n_path.AppendASCII(current_locale);
+ ASSERT_TRUE(file_util::CreateDirectory(l10n_path));
+
+ ASSERT_TRUE(file_util::WriteFile(l10n_path.AppendASCII(filename),
+ data.c_str(), data.length()));
+
+ FilePath path;
+ ExtensionResource resource(temp.path(), FilePath().AppendASCII(filename));
+ FilePath resolved_path = resource.GetFilePath();
+
+ EXPECT_TRUE(l10n_path.AppendASCII(filename) == resolved_path);
+ EXPECT_TRUE(temp.path() == resource.extension_root());
+ EXPECT_TRUE(FilePath().AppendASCII(filename) == resource.relative_path());
+}
Property changes on: chrome\common\extensions\extension_resource_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/common/extensions/extension_resource.cc ('k') | chrome/common/extensions/extension_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698