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

Side by Side Diff: ui/base/resource/resource_bundle_unittest.cc

Issue 7779019: Removed sample.pak binary from checkout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated. Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/resource/data_pack_unittest.cc ('k') | ui/base/test/data/data_pack_unittest/sample.pak » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/base/resource/resource_bundle.h" 5 #include "ui/base/resource/resource_bundle.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h"
9 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/scoped_temp_dir.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 13
12 namespace ui { 14 namespace ui {
13 15
16 extern const char kSamplePakContents[];
17 extern const size_t kSamplePakSize;
18
14 TEST(ResourceBundle, LoadDataResourceBytes) { 19 TEST(ResourceBundle, LoadDataResourceBytes) {
15 // Verify that we don't crash when trying to load a resource that is not 20 // Verify that we don't crash when trying to load a resource that is not
16 // found. In some cases, we fail to mmap resources.pak, but try to keep 21 // found. In some cases, we fail to mmap resources.pak, but try to keep
17 // going anyway. 22 // going anyway.
18 ResourceBundle resource_bundle; 23 ResourceBundle resource_bundle;
19 24
20 // On Windows, the default data is compiled into the binary so this does 25 // On Windows, the default data is compiled into the binary so this does
21 // nothing. 26 // nothing.
22 FilePath data_path; 27 ScopedTempDir dir;
23 PathService::Get(base::DIR_SOURCE_ROOT, &data_path); 28 ASSERT_TRUE(dir.CreateUniqueTempDir());
24 data_path = data_path.Append( 29 FilePath data_path = dir.path().Append(FILE_PATH_LITERAL("sample.pak"));
25 FILE_PATH_LITERAL("ui/base/test/data/data_pack_unittest/sample.pak"));
26 30
31 // Dump contents into the pak file.
32 ASSERT_EQ(file_util::WriteFile(data_path, kSamplePakContents, kSamplePakSize),
33 static_cast<int>(kSamplePakSize));
34
35 // Create a resource bundle from the file.
27 resource_bundle.LoadTestResources(data_path); 36 resource_bundle.LoadTestResources(data_path);
28 37
29 const int kUnfoundResourceId = 10000; 38 const int kUnfoundResourceId = 10000;
30 EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes(kUnfoundResourceId)); 39 EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes(kUnfoundResourceId));
31 40
32 // Give a .pak file that doesn't exist so we will fail to load it. 41 // Give a .pak file that doesn't exist so we will fail to load it.
33 resource_bundle.AddDataPackToSharedInstance(FilePath( 42 resource_bundle.AddDataPackToSharedInstance(FilePath(
34 FILE_PATH_LITERAL("non-existant-file.pak"))); 43 FILE_PATH_LITERAL("non-existant-file.pak")));
35 EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes(kUnfoundResourceId)); 44 EXPECT_EQ(NULL, resource_bundle.LoadDataResourceBytes(kUnfoundResourceId));
36 } 45 }
37 46
38 } // namespace ui 47 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/data_pack_unittest.cc ('k') | ui/base/test/data/data_pack_unittest/sample.pak » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698