Chromium Code Reviews| Index: ui/base/resource/resource_bundle_unittest.cc |
| diff --git a/ui/base/resource/resource_bundle_unittest.cc b/ui/base/resource/resource_bundle_unittest.cc |
| index 9e4f12c4f418dfd197af1bed07d60ffd63625f07..f3e6774ab1ad56cf22468cb0dd49acd844de03ef 100644 |
| --- a/ui/base/resource/resource_bundle_unittest.cc |
| +++ b/ui/base/resource/resource_bundle_unittest.cc |
| @@ -6,11 +6,16 @@ |
| #include "base/base_paths.h" |
| #include "base/file_path.h" |
| +#include "base/file_util.h" |
| #include "base/path_service.h" |
| +#include "base/scoped_temp_dir.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace ui { |
| +extern const char kSamplePakContents[]; |
| +extern const size_t kSamplePakSize; |
| + |
| TEST(ResourceBundle, LoadDataResourceBytes) { |
| // Verify that we don't crash when trying to load a resource that is not |
| // found. In some cases, we fail to mmap resources.pak, but try to keep |
| @@ -19,11 +24,18 @@ TEST(ResourceBundle, LoadDataResourceBytes) { |
| // On Windows, the default data is compiled into the binary so this does |
| // nothing. |
| - FilePath data_path; |
| - PathService::Get(base::DIR_SOURCE_ROOT, &data_path); |
| - data_path = data_path.Append( |
| - FILE_PATH_LITERAL("ui/base/test/data/data_pack_unittest/sample.pak")); |
| - |
| + ScopedTempDir dir; |
| + ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| + FilePath data_path = dir.path().Append(FILE_PATH_LITERAL("sample.pak")); |
| + |
| + // Dump contents into the pak file. |
| + FILE* file = file_util::OpenFile(data_path, "wb"); |
|
tony
2011/09/02 23:10:51
Can we just use file_util::WriteFile?
marcvs
2011/09/02 23:27:27
Done.
|
| + ASSERT_TRUE(file); |
| + ASSERT_EQ(fwrite(kSamplePakContents, 1, kSamplePakSize, file), |
| + kSamplePakSize); |
| + file_util::CloseFile(file); |
| + |
| + // Create a resource bundle from the file. |
| resource_bundle.LoadTestResources(data_path); |
| const int kUnfoundResourceId = 10000; |