| OLD | NEW |
| 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 "chrome/common/extensions/extension_file_util.h" | 5 #include "chrome/common/extensions/extension_file_util.h" |
| 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/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 " For the path " << actual_path.value(); | 297 " For the path " << actual_path.value(); |
| 298 EXPECT_EQ(expected_path.value(), actual_path.value()) << | 298 EXPECT_EQ(expected_path.value(), actual_path.value()) << |
| 299 " For the path " << url; | 299 " For the path " << url; |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| 303 TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) { | 303 TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) { |
| 304 // Setup filesystem for testing. | 304 // Setup filesystem for testing. |
| 305 base::FilePath root_path; | 305 base::FilePath root_path; |
| 306 ASSERT_TRUE(file_util::CreateNewTempDirectory( | 306 ASSERT_TRUE(file_util::CreateNewTempDirectory( |
| 307 FILE_PATH_LITERAL(""), &root_path)); | 307 base::FilePath::StringType(), &root_path)); |
| 308 ASSERT_TRUE(file_util::AbsolutePath(&root_path)); | 308 ASSERT_TRUE(file_util::AbsolutePath(&root_path)); |
| 309 | 309 |
| 310 base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname")); | 310 base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname")); |
| 311 ASSERT_TRUE(file_util::CreateDirectory(api_path)); | 311 ASSERT_TRUE(file_util::CreateDirectory(api_path)); |
| 312 | 312 |
| 313 const char data[] = "Test Data"; | 313 const char data[] = "Test Data"; |
| 314 base::FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js")); | 314 base::FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js")); |
| 315 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); | 315 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); |
| 316 resource_path = api_path.Append(FILE_PATH_LITERAL("escape spaces.js")); | 316 resource_path = api_path.Append(FILE_PATH_LITERAL("escape spaces.js")); |
| 317 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); | 317 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( | 593 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( |
| 594 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); | 594 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); |
| 595 EXPECT_TRUE(extension3 == NULL); | 595 EXPECT_TRUE(extension3 == NULL); |
| 596 EXPECT_STREQ("Could not load icon 'icon.png' for page action.", | 596 EXPECT_STREQ("Could not load icon 'icon.png' for page action.", |
| 597 error.c_str()); | 597 error.c_str()); |
| 598 } | 598 } |
| 599 | 599 |
| 600 // TODO(aa): More tests as motivation allows. Maybe steal some from | 600 // TODO(aa): More tests as motivation allows. Maybe steal some from |
| 601 // ExtensionService? Many of them could probably be tested here without the | 601 // ExtensionService? Many of them could probably be tested here without the |
| 602 // MessageLoop shenanigans. | 602 // MessageLoop shenanigans. |
| OLD | NEW |