| 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 "ash/test/test_suite.h" | 5 #include "ash/test/test_suite.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/test/ash_test_environment.h" |
| 8 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 10 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/base/ui_base_paths.h" | 17 #include "ui/base/ui_base_paths.h" |
| 17 #include "ui/gfx/gfx_paths.h" | 18 #include "ui/gfx/gfx_paths.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 52 |
| 52 // Force unittests to run using en-US so if we test against string output, | 53 // Force unittests to run using en-US so if we test against string output, |
| 53 // it'll pass regardless of the system language. | 54 // it'll pass regardless of the system language. |
| 54 base::i18n::SetICUDefaultLocale("en_US"); | 55 base::i18n::SetICUDefaultLocale("en_US"); |
| 55 | 56 |
| 56 // Load ash test resources and en-US strings; not 'common' (Chrome) resources. | 57 // Load ash test resources and en-US strings; not 'common' (Chrome) resources. |
| 57 base::FilePath path; | 58 base::FilePath path; |
| 58 PathService::Get(base::DIR_MODULE, &path); | 59 PathService::Get(base::DIR_MODULE, &path); |
| 59 base::FilePath ash_test_strings = | 60 base::FilePath ash_test_strings = |
| 60 path.Append(FILE_PATH_LITERAL("ash_test_strings.pak")); | 61 path.Append(FILE_PATH_LITERAL("ash_test_strings.pak")); |
| 61 base::FilePath ash_test_resources_100 = | 62 ui::ResourceBundle::InitSharedInstanceWithPakPath(ash_test_strings); |
| 62 path.Append(FILE_PATH_LITERAL("ash_test_resources_100_percent.pak")); | |
| 63 base::FilePath ash_test_resources_200 = | |
| 64 path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak")); | |
| 65 | 63 |
| 66 ui::ResourceBundle::InitSharedInstanceWithPakPath(ash_test_strings); | 64 if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_100P)) { |
| 67 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 65 base::FilePath ash_test_resources_100 = |
| 68 if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_100P)) | 66 path.AppendASCII(AshTestEnvironment::Get100PercentResourceFileName()); |
| 69 rb.AddDataPackFromPath(ash_test_resources_100, ui::SCALE_FACTOR_100P); | 67 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 70 if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_200P)) | 68 ash_test_resources_100, ui::SCALE_FACTOR_100P); |
| 71 rb.AddDataPackFromPath(ash_test_resources_200, ui::SCALE_FACTOR_200P); | 69 } |
| 70 if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_200P)) { |
| 71 base::FilePath ash_test_resources_200 = |
| 72 path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak")); |
| 73 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 74 ash_test_resources_200, ui::SCALE_FACTOR_200P); |
| 75 } |
| 72 | 76 |
| 73 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); | 77 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); |
| 74 env_ = aura::Env::CreateInstance(); | 78 env_ = aura::Env::CreateInstance(); |
| 75 } | 79 } |
| 76 | 80 |
| 77 void AuraShellTestSuite::Shutdown() { | 81 void AuraShellTestSuite::Shutdown() { |
| 78 env_.reset(); | 82 env_.reset(); |
| 79 ui::ResourceBundle::CleanupSharedInstance(); | 83 ui::ResourceBundle::CleanupSharedInstance(); |
| 80 #if defined(OS_WIN) | 84 #if defined(OS_WIN) |
| 81 com_initializer_.reset(); | 85 com_initializer_.reset(); |
| 82 #endif | 86 #endif |
| 83 base::TestSuite::Shutdown(); | 87 base::TestSuite::Shutdown(); |
| 84 } | 88 } |
| 85 | 89 |
| 86 } // namespace test | 90 } // namespace test |
| 87 } // namespace ash | 91 } // namespace ash |
| OLD | NEW |