summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/chrome_common.gypi2
-rw-r--r--chrome/chrome_tests_unit.gypi7
-rw-r--r--chrome/test/base/chrome_test_suite.cc3
-rw-r--r--chrome/unit_tests.isolate1
-rw-r--r--extensions/DEPS2
-rw-r--r--extensions/browser/file_reader_unittest.cc26
-rw-r--r--extensions/common/extension_paths.cc41
-rw-r--r--extensions/common/extension_paths.h27
-rw-r--r--extensions/common/extension_resource_unittest.cc4
9 files changed, 93 insertions, 20 deletions
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 24430bc..b3978ac 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -68,6 +68,8 @@
'../extensions/common/event_filtering_info.h',
'../extensions/common/event_matcher.cc',
'../extensions/common/event_matcher.h',
+ '../extensions/common/extension_paths.cc',
+ '../extensions/common/extension_paths.h',
'../extensions/common/extension_resource.cc',
'../extensions/common/extension_resource.h',
'../extensions/common/id_util.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 9507b05..0af5846 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -92,8 +92,8 @@
'browser/chromeos/login/mock_user_image_manager.h',
'browser/chromeos/login/mock_user_manager.cc',
'browser/chromeos/login/mock_user_manager.h',
- 'browser/chromeos/net/mock_connectivity_state_helper.cc',
- 'browser/chromeos/net/mock_connectivity_state_helper.h',
+ 'browser/chromeos/net/mock_connectivity_state_helper.cc',
+ 'browser/chromeos/net/mock_connectivity_state_helper.h',
'browser/chromeos/policy/device_policy_builder.cc',
'browser/chromeos/policy/device_policy_builder.h',
'browser/chromeos/settings/device_settings_test_helper.cc',
@@ -1454,7 +1454,7 @@
'browser/ui/webui/performance_monitor/performance_monitor_ui_util_unittest.cc',
'browser/ui/webui/print_preview/print_preview_ui_unittest.cc',
'browser/ui/webui/signin/login_ui_service_unittest.cc',
- 'browser/ui/webui/signin/profile_signin_confirmation_dialog_unittest.cc',
+ 'browser/ui/webui/signin/profile_signin_confirmation_dialog_unittest.cc',
'browser/ui/webui/sync_internals_ui_unittest.cc',
'browser/ui/webui/sync_setup_handler_unittest.cc',
'browser/ui/webui/theme_source_unittest.cc',
@@ -1818,6 +1818,7 @@
}],
['enable_extensions==0', {
'sources/': [
+ ['exclude', '^../extensions/'],
['exclude', '^browser/extensions/activity_database_unittest.cc'],
['exclude', '^browser/extensions/activity_log_unittest.cc'],
['exclude', '^browser/extensions/api/'],
diff --git a/chrome/test/base/chrome_test_suite.cc b/chrome/test/base/chrome_test_suite.cc
index 26d359e..62a85ab 100644
--- a/chrome/test/base/chrome_test_suite.cc
+++ b/chrome/test/base/chrome_test_suite.cc
@@ -26,6 +26,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/testing_browser_process.h"
#include "content/public/test/test_launcher.h"
+#include "extensions/common/extension_paths.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/dns/mock_host_resolver.h"
@@ -216,6 +217,8 @@ void ChromeTestSuite::Initialize() {
}
#if !defined(OS_IOS)
+ extensions::RegisterPathProvider();
+
if (!content::GetCurrentTestLauncherDelegate()) {
// Only want to do this for unit tests. For browser tests, this won't create
// the right object since TestChromeWebUIControllerFactory is used. That's
diff --git a/chrome/unit_tests.isolate b/chrome/unit_tests.isolate
index 591d7ad..4f5d740 100644
--- a/chrome/unit_tests.isolate
+++ b/chrome/unit_tests.isolate
@@ -10,6 +10,7 @@
],
'isolate_dependency_untracked': [
'../base/prefs/test/data/',
+ '../extensions/test/data/',
'../net/data/',
'../net/tools/testserver/',
'../testing/test_env.py',
diff --git a/extensions/DEPS b/extensions/DEPS
index 68da161..64d7efd 100644
--- a/extensions/DEPS
+++ b/extensions/DEPS
@@ -10,8 +10,6 @@ include_rules = [
# More specific rules for what we are allowed to include.
specific_include_rules = {
".*test\.cc": [
- # For chrome::TEST_DATA_DIR; test data should be migrated to src/extensions.
- "+chrome/common/chrome_paths.h",
"+content/public/test",
]
}
diff --git a/extensions/browser/file_reader_unittest.cc b/extensions/browser/file_reader_unittest.cc
index 3c3a4d2..a382cbe 100644
--- a/extensions/browser/file_reader_unittest.cc
+++ b/extensions/browser/file_reader_unittest.cc
@@ -8,16 +8,16 @@
#include "base/files/file_path.h"
#include "base/message_loop.h"
#include "base/path_service.h"
-#include "chrome/common/chrome_paths.h"
#include "content/public/test/test_browser_thread.h"
#include "extensions/browser/file_reader.h"
+#include "extensions/common/extension_paths.h"
#include "extensions/common/extension_resource.h"
#include "extensions/common/id_util.h"
#include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread;
-namespace {
+namespace extensions {
class FileReaderTest : public testing::Test {
public:
@@ -54,14 +54,14 @@ class Receiver {
void RunBasicTest(const char* filename) {
base::FilePath path;
- PathService::Get(chrome::DIR_TEST_DATA, &path);
- std::string extension_id = extensions::id_util::GenerateId("test");
- extensions::ExtensionResource resource(
+ PathService::Get(DIR_TEST_DATA, &path);
+ std::string extension_id = id_util::GenerateId("test");
+ ExtensionResource resource(
extension_id, path, base::FilePath().AppendASCII(filename));
path = path.AppendASCII(filename);
std::string file_contents;
- bool file_exists = file_util::ReadFileToString(path, &file_contents);
+ ASSERT_TRUE(file_util::ReadFileToString(path, &file_contents));
Receiver receiver;
@@ -71,23 +71,23 @@ void RunBasicTest(const char* filename) {
MessageLoop::current()->Run();
- EXPECT_EQ(file_exists, receiver.succeeded());
+ EXPECT_TRUE(receiver.succeeded());
EXPECT_EQ(file_contents, receiver.data());
}
TEST_F(FileReaderTest, SmallFile) {
- RunBasicTest("title1.html");
+ RunBasicTest("smallfile");
}
TEST_F(FileReaderTest, BiggerFile) {
- RunBasicTest("download-test1.lib");
+ RunBasicTest("bigfile");
}
TEST_F(FileReaderTest, NonExistantFile) {
base::FilePath path;
- PathService::Get(chrome::DIR_TEST_DATA, &path);
- std::string extension_id = extensions::id_util::GenerateId("test");
- extensions::ExtensionResource resource(extension_id, path, base::FilePath(
+ PathService::Get(DIR_TEST_DATA, &path);
+ std::string extension_id = id_util::GenerateId("test");
+ ExtensionResource resource(extension_id, path, base::FilePath(
FILE_PATH_LITERAL("file_that_does_not_exist")));
path = path.AppendASCII("file_that_does_not_exist");
@@ -102,4 +102,4 @@ TEST_F(FileReaderTest, NonExistantFile) {
EXPECT_FALSE(receiver.succeeded());
}
-} // namespace
+} // namespace extensions
diff --git a/extensions/common/extension_paths.cc b/extensions/common/extension_paths.cc
new file mode 100644
index 0000000..deec7d9
--- /dev/null
+++ b/extensions/common/extension_paths.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2013 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 "extensions/common/extension_paths.h"
+
+#include "base/file_util.h"
+#include "base/path_service.h"
+
+namespace extensions {
+
+bool PathProvider(int key, base::FilePath* result) {
+ switch (key) {
+ case DIR_TEST_DATA: {
+ base::FilePath cur;
+ if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
+ return false;
+ cur = cur.Append(FILE_PATH_LITERAL("extensions"));
+ cur = cur.Append(FILE_PATH_LITERAL("test"));
+ cur = cur.Append(FILE_PATH_LITERAL("data"));
+ if (!file_util::PathExists(cur)) // we don't want to create this
+ return false;
+
+ *result = cur;
+ return true;
+ break;
+ }
+ default:
+ return false;
+ }
+
+ return false;
+}
+
+// This cannot be done as a static initializer sadly since Visual Studio will
+// eliminate this object file if there is no direct entry point into it.
+void RegisterPathProvider() {
+ PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
+}
+
+} // namespace extensions
diff --git a/extensions/common/extension_paths.h b/extensions/common/extension_paths.h
new file mode 100644
index 0000000..bbeff6a
--- /dev/null
+++ b/extensions/common/extension_paths.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2013 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.
+
+#ifndef EXTENSIONS_COMMON_EXTENSION_PATHS_H_
+#define EXTENSIONS_COMMON_EXTENSION_PATHS_H_
+
+// This file declares path keys for extensions. These can be used with
+// the PathService to access various special directories and files.
+
+namespace extensions {
+
+enum {
+ PATH_START = 6000,
+
+ // Valid only in development environment
+ DIR_TEST_DATA,
+
+ PATH_END
+};
+
+// Call once to register the provider for the path keys defined above.
+void RegisterPathProvider();
+
+} // namespace extensions
+
+#endif // EXTENSIONS_COMMON_EXTENSION_PATHS_H_
diff --git a/extensions/common/extension_resource_unittest.cc b/extensions/common/extension_resource_unittest.cc
index b2983ea..132e718 100644
--- a/extensions/common/extension_resource_unittest.cc
+++ b/extensions/common/extension_resource_unittest.cc
@@ -7,8 +7,8 @@
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
-#include "chrome/common/chrome_paths.h"
#include "extensions/common/constants.h"
+#include "extensions/common/extension_paths.h"
#include "extensions/common/extension_resource.h"
#include "extensions/common/id_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -33,7 +33,7 @@ const base::FilePath::StringType ToLower(
TEST(ExtensionResourceTest, CreateWithMissingResourceOnDisk) {
base::FilePath root_path;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &root_path));
+ ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &root_path));
base::FilePath relative_path;
relative_path = relative_path.AppendASCII("cira.js");
std::string extension_id = id_util::GenerateId("test");