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/ash_test_suite.h" | 5 #include "ash/test/ash_test_suite.h" |
6 | 6 |
7 #include "ash/public/cpp/config.h" | |
7 #include "ash/test/ash_test_environment.h" | 8 #include "ash/test/ash_test_environment.h" |
9 #include "ash/test/ash_test_helper.h" | |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
11 #include "base/path_service.h" | 13 #include "base/path_service.h" |
12 #include "build/build_config.h" | 14 #include "build/build_config.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/base/ui_base_paths.h" | 17 #include "ui/base/ui_base_paths.h" |
18 #include "ui/compositor/test/fake_context_factory.h" | |
16 #include "ui/gfx/gfx_paths.h" | 19 #include "ui/gfx/gfx_paths.h" |
17 #include "ui/gl/test/gl_surface_test_support.h" | 20 #include "ui/gl/test/gl_surface_test_support.h" |
18 | 21 |
19 namespace ash { | 22 namespace ash { |
20 namespace test { | 23 namespace test { |
21 | 24 |
22 AshTestSuite::AshTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} | 25 AshTestSuite::AshTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} |
23 | 26 |
24 AshTestSuite::~AshTestSuite() {} | 27 AshTestSuite::~AshTestSuite() {} |
25 | 28 |
(...skipping 21 matching lines...) Expand all Loading... | |
47 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 50 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
48 ash_test_resources_100, ui::SCALE_FACTOR_100P); | 51 ash_test_resources_100, ui::SCALE_FACTOR_100P); |
49 } | 52 } |
50 if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_200P)) { | 53 if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_200P)) { |
51 base::FilePath ash_test_resources_200 = | 54 base::FilePath ash_test_resources_200 = |
52 path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak")); | 55 path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak")); |
53 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 56 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
54 ash_test_resources_200, ui::SCALE_FACTOR_200P); | 57 ash_test_resources_200, ui::SCALE_FACTOR_200P); |
55 } | 58 } |
56 | 59 |
60 const bool is_classic = | |
msw
2017/03/30 23:06:05
optional nit: is_mus would be a one-liner.
sky
2017/03/30 23:35:46
Nice!
| |
61 !base::CommandLine::ForCurrentProcess()->HasSwitch("mus"); | |
62 ash::test::AshTestHelper::config_ = | |
63 is_classic ? Config::CLASSIC : Config::MUS; | |
64 | |
57 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); | 65 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); |
58 env_ = aura::Env::CreateInstance(); | 66 env_ = aura::Env::CreateInstance(is_classic ? aura::Env::Mode::LOCAL |
67 : aura::Env::Mode::MUS); | |
68 | |
69 if (!is_classic) { | |
70 context_factory_ = base::MakeUnique<ui::FakeContextFactory>(); | |
71 env_->set_context_factory(context_factory_.get()); | |
72 env_->set_context_factory_private(nullptr); | |
73 } | |
59 } | 74 } |
60 | 75 |
61 void AshTestSuite::Shutdown() { | 76 void AshTestSuite::Shutdown() { |
62 env_.reset(); | 77 env_.reset(); |
63 ui::ResourceBundle::CleanupSharedInstance(); | 78 ui::ResourceBundle::CleanupSharedInstance(); |
64 base::TestSuite::Shutdown(); | 79 base::TestSuite::Shutdown(); |
65 } | 80 } |
66 | 81 |
67 } // namespace test | 82 } // namespace test |
68 } // namespace ash | 83 } // namespace ash |
OLD | NEW |