| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "mash/test/mash_test_suite.h" | 5 #include "mash/test/mash_test_suite.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 8 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 9 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
| 11 #include "ui/base/ui_base_paths.h" | 12 #include "ui/base/ui_base_paths.h" |
| 12 #include "ui/compositor/test/context_factories_for_test.h" | 13 #include "ui/compositor/test/context_factories_for_test.h" |
| 14 #include "ui/gl/gl_switches.h" |
| 13 #include "ui/gl/test/gl_surface_test_support.h" | 15 #include "ui/gl/test/gl_surface_test_support.h" |
| 14 | 16 |
| 15 namespace mash { | 17 namespace mash { |
| 16 namespace test { | 18 namespace test { |
| 17 | 19 |
| 18 MashTestSuite::MashTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} | 20 MashTestSuite::MashTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} |
| 19 | 21 |
| 20 MashTestSuite::~MashTestSuite() {} | 22 MashTestSuite::~MashTestSuite() {} |
| 21 | 23 |
| 22 void MashTestSuite::Initialize() { | 24 void MashTestSuite::Initialize() { |
| 23 base::TestSuite::Initialize(); | 25 base::TestSuite::Initialize(); |
| 24 | 26 |
| 27 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 28 switches::kOverrideUseGLWithOSMesaForTests); |
| 29 |
| 25 // Load ash mus strings and resources; not 'common' (Chrome) resources. | 30 // Load ash mus strings and resources; not 'common' (Chrome) resources. |
| 26 base::FilePath resources; | 31 base::FilePath resources; |
| 27 PathService::Get(base::DIR_MODULE, &resources); | 32 PathService::Get(base::DIR_MODULE, &resources); |
| 28 resources = resources.Append(FILE_PATH_LITERAL("ash_mus_resources.pak")); | 33 resources = resources.Append(FILE_PATH_LITERAL("ash_mus_resources.pak")); |
| 29 ui::ResourceBundle::InitSharedInstanceWithPakPath(resources); | 34 ui::ResourceBundle::InitSharedInstanceWithPakPath(resources); |
| 30 | 35 |
| 31 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); | 36 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); |
| 32 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); | 37 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); |
| 33 gl::GLSurfaceTestSupport::InitializeOneOff(); | 38 gl::GLSurfaceTestSupport::InitializeOneOff(); |
| 34 const bool enable_pixel_output = false; | 39 const bool enable_pixel_output = false; |
| 35 | 40 |
| 36 ui::ContextFactory* context_factory = nullptr; | 41 ui::ContextFactory* context_factory = nullptr; |
| 37 ui::ContextFactoryPrivate* context_factory_private = nullptr; | 42 ui::ContextFactoryPrivate* context_factory_private = nullptr; |
| 38 ui::InitializeContextFactoryForTests(enable_pixel_output, &context_factory, | 43 ui::InitializeContextFactoryForTests(enable_pixel_output, &context_factory, |
| 39 &context_factory_private); | 44 &context_factory_private); |
| 40 | 45 |
| 41 env_->set_context_factory(context_factory); | 46 env_->set_context_factory(context_factory); |
| 42 env_->set_context_factory_private(context_factory_private); | 47 env_->set_context_factory_private(context_factory_private); |
| 43 } | 48 } |
| 44 | 49 |
| 45 void MashTestSuite::Shutdown() { | 50 void MashTestSuite::Shutdown() { |
| 46 ui::TerminateContextFactoryForTests(); | 51 ui::TerminateContextFactoryForTests(); |
| 47 env_.reset(); | 52 env_.reset(); |
| 48 ui::ResourceBundle::CleanupSharedInstance(); | 53 ui::ResourceBundle::CleanupSharedInstance(); |
| 49 base::TestSuite::Shutdown(); | 54 base::TestSuite::Shutdown(); |
| 50 } | 55 } |
| 51 | 56 |
| 52 } // namespace test | 57 } // namespace test |
| 53 } // namespace mash | 58 } // namespace mash |
| OLD | NEW |