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

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

Issue 11359217: Move scoped_temp_dir from base to base/files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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') | webkit/appcache/appcache_database_unittest.cc » ('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) 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 "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/file_util.h"
10 #include "base/files/scoped_temp_dir.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
12 #include "base/path_service.h" 13 #include "base/path_service.h"
13 #include "base/scoped_temp_dir.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "net/base/big_endian.h" 15 #include "net/base/big_endian.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "ui/base/layout.h" 19 #include "ui/base/layout.h"
20 #include "ui/base/resource/data_pack.h" 20 #include "ui/base/resource/data_pack.h"
21 #include "ui/gfx/codec/png_codec.h" 21 #include "ui/gfx/codec/png_codec.h"
22 #include "ui/gfx/image/image_skia.h" 22 #include "ui/gfx/image/image_skia.h"
23 23
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // Load the empty locale data pak. 353 // Load the empty locale data pak.
354 resource_bundle->LoadTestResources(FilePath(), locale_path); 354 resource_bundle->LoadTestResources(FilePath(), locale_path);
355 return resource_bundle; 355 return resource_bundle;
356 } 356 }
357 357
358 // Returns the path of temporary directory to write test data packs into. 358 // Returns the path of temporary directory to write test data packs into.
359 const FilePath& dir_path() { return dir_.path(); } 359 const FilePath& dir_path() { return dir_.path(); }
360 360
361 private: 361 private:
362 scoped_ptr<DataPack> locale_pack_; 362 scoped_ptr<DataPack> locale_pack_;
363 ScopedTempDir dir_; 363 base::ScopedTempDir dir_;
364 364
365 DISALLOW_COPY_AND_ASSIGN(ResourceBundleImageTest); 365 DISALLOW_COPY_AND_ASSIGN(ResourceBundleImageTest);
366 }; 366 };
367 367
368 // Verify that we don't crash when trying to load a resource that is not found. 368 // Verify that we don't crash when trying to load a resource that is not found.
369 // In some cases, we fail to mmap resources.pak, but try to keep going anyway. 369 // In some cases, we fail to mmap resources.pak, but try to keep going anyway.
370 TEST_F(ResourceBundleImageTest, LoadDataResourceBytes) { 370 TEST_F(ResourceBundleImageTest, LoadDataResourceBytes) {
371 FilePath data_path = dir_path().Append(FILE_PATH_LITERAL("sample.pak")); 371 FilePath data_path = dir_path().Append(FILE_PATH_LITERAL("sample.pak"));
372 372
373 // Dump contents into the pak files. 373 // Dump contents into the pak files.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak(); 501 ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
502 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); 502 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE);
503 503
504 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); 504 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3);
505 EXPECT_EQ(1u, image_skia->image_reps().size()); 505 EXPECT_EQ(1u, image_skia->image_reps().size());
506 EXPECT_EQ(ui::SCALE_FACTOR_100P, 506 EXPECT_EQ(ui::SCALE_FACTOR_100P,
507 image_skia->image_reps()[0].scale_factor()); 507 image_skia->image_reps()[0].scale_factor());
508 } 508 }
509 509
510 } // namespace ui 510 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/data_pack_unittest.cc ('k') | webkit/appcache/appcache_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698