| 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
|
|
|
|
|