| 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 "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 size_t num_material_packs = 0; | 388 size_t num_material_packs = 0; |
| 389 for (size_t i = 0; i < resource_bundle->data_packs_.size(); i++) { | 389 for (size_t i = 0; i < resource_bundle->data_packs_.size(); i++) { |
| 390 if (resource_bundle->data_packs_[i]->HasOnlyMaterialDesignAssets()) | 390 if (resource_bundle->data_packs_[i]->HasOnlyMaterialDesignAssets()) |
| 391 num_material_packs++; | 391 num_material_packs++; |
| 392 } | 392 } |
| 393 | 393 |
| 394 return num_material_packs; | 394 return num_material_packs; |
| 395 } | 395 } |
| 396 | 396 |
| 397 private: | 397 private: |
| 398 scoped_ptr<DataPack> locale_pack_; | 398 std::unique_ptr<DataPack> locale_pack_; |
| 399 base::ScopedTempDir dir_; | 399 base::ScopedTempDir dir_; |
| 400 | 400 |
| 401 DISALLOW_COPY_AND_ASSIGN(ResourceBundleImageTest); | 401 DISALLOW_COPY_AND_ASSIGN(ResourceBundleImageTest); |
| 402 }; | 402 }; |
| 403 | 403 |
| 404 // Verify that we don't crash when trying to load a resource that is not found. | 404 // Verify that we don't crash when trying to load a resource that is not found. |
| 405 // In some cases, we fail to mmap resources.pak, but try to keep going anyway. | 405 // In some cases, we fail to mmap resources.pak, but try to keep going anyway. |
| 406 TEST_F(ResourceBundleImageTest, LoadDataResourceBytes) { | 406 TEST_F(ResourceBundleImageTest, LoadDataResourceBytes) { |
| 407 base::FilePath data_path = dir_path().Append(FILE_PATH_LITERAL("sample.pak")); | 407 base::FilePath data_path = dir_path().Append(FILE_PATH_LITERAL("sample.pak")); |
| 408 | 408 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); | 704 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); |
| 705 | 705 |
| 706 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); | 706 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); |
| 707 EXPECT_EQ(1u, image_skia->image_reps().size()); | 707 EXPECT_EQ(1u, image_skia->image_reps().size()); |
| 708 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); | 708 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); |
| 709 EXPECT_EQ(ui::SCALE_FACTOR_100P, | 709 EXPECT_EQ(ui::SCALE_FACTOR_100P, |
| 710 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); | 710 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); |
| 711 } | 711 } |
| 712 | 712 |
| 713 } // namespace ui | 713 } // namespace ui |
| OLD | NEW |