[email protected] | 578c81b | 2012-01-27 07:25:02 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 2f74428 | 2011-12-23 22:40:52 | [diff] [blame] | 5 | #include "ash/test/test_suite.h" |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 6 | |
msw | d9b1b34 | 2016-06-17 20:19:57 | [diff] [blame] | 7 | #include "ash/common/ash_switches.h" |
[email protected] | e9a3b0cf | 2013-03-25 20:23:41 | [diff] [blame] | 8 | #include "base/command_line.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 9 | #include "base/files/file_path.h" |
msw | 40ddaa81f | 2016-02-10 00:26:16 | [diff] [blame] | 10 | #include "base/i18n/rtl.h" |
11 | #include "base/path_service.h" | ||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 12 | #include "build/build_config.h" |
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 13 | #include "testing/gtest/include/gtest/gtest.h" |
sadrul | 679eb98f | 2015-08-07 05:25:10 | [diff] [blame] | 14 | #include "ui/aura/env.h" |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 15 | #include "ui/base/resource/resource_bundle.h" |
16 | #include "ui/base/ui_base_paths.h" | ||||
17 | #include "ui/gfx/gfx_paths.h" | ||||
sadrul | ba162cd | 2015-07-20 22:34:26 | [diff] [blame] | 18 | #include "ui/gl/test/gl_surface_test_support.h" |
[email protected] | 72f08de | 2011-12-09 16:19:03 | [diff] [blame] | 19 | |
[email protected] | 1c3f700 | 2013-01-21 18:46:05 | [diff] [blame] | 20 | #if defined(OS_WIN) |
21 | #include "base/win/windows_version.h" | ||||
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 22 | #include "ui/base/win/atl_module.h" |
[email protected] | 1c3f700 | 2013-01-21 18:46:05 | [diff] [blame] | 23 | #endif |
24 | |||||
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 25 | namespace ash { |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 26 | namespace test { |
27 | |||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 28 | AuraShellTestSuite::AuraShellTestSuite(int argc, char** argv) |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 29 | : TestSuite(argc, argv) {} |
thakis | 94b3605 | 2015-04-30 20:07:48 | [diff] [blame] | 30 | |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 31 | AuraShellTestSuite::~AuraShellTestSuite() {} |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 32 | |
33 | void AuraShellTestSuite::Initialize() { | ||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 34 | base::TestSuite::Initialize(); |
kylechar | 7a46384 | 2016-05-26 14:46:12 | [diff] [blame] | 35 | gl::GLSurfaceTestSupport::InitializeOneOff(); |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 36 | |
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 37 | #if defined(OS_WIN) |
[email protected] | cb1782c2 | 2014-03-12 19:44:05 | [diff] [blame] | 38 | base::win::Version version = base::win::GetVersion(); |
39 | // Although Ash officially is only supported for users on Win7+, we still run | ||||
40 | // ash_unittests on Vista builders, so we still need to initialize COM. | ||||
41 | if (version >= base::win::VERSION_VISTA && | ||||
pgal.u-szeged | d84534d3 | 2014-10-29 12:34:30 | [diff] [blame] | 42 | !base::CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | e9a3b0cf | 2013-03-25 20:23:41 | [diff] [blame] | 43 | ash::switches::kForceAshToDesktop)) { |
[email protected] | b84f821c | 2013-05-28 17:56:09 | [diff] [blame] | 44 | com_initializer_.reset(new base::win::ScopedCOMInitializer()); |
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 45 | ui::win::CreateATLModuleIfNeeded(); |
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 46 | } |
47 | #endif | ||||
48 | |||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 49 | gfx::RegisterPathProvider(); |
50 | ui::RegisterPathProvider(); | ||||
51 | |||||
msw | 40ddaa81f | 2016-02-10 00:26:16 | [diff] [blame] | 52 | // Force unittests to run using en-US so if we test against string output, |
53 | // it'll pass regardless of the system language. | ||||
54 | base::i18n::SetICUDefaultLocale("en_US"); | ||||
55 | |||||
msw | d04d3ef3 | 2016-07-18 23:43:08 | [diff] [blame] | 56 | // Load ash test resources and en-US strings; not 'common' (Chrome) resources. |
msw | 40ddaa81f | 2016-02-10 00:26:16 | [diff] [blame] | 57 | base::FilePath path; |
58 | PathService::Get(base::DIR_MODULE, &path); | ||||
59 | base::FilePath ash_test_strings = | ||||
60 | path.Append(FILE_PATH_LITERAL("ash_test_strings.pak")); | ||||
61 | base::FilePath ash_test_resources_100 = | ||||
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 | |||||
66 | ui::ResourceBundle::InitSharedInstanceWithPakPath(ash_test_strings); | ||||
67 | ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | ||||
msw | d04d3ef3 | 2016-07-18 23:43:08 | [diff] [blame] | 68 | if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_100P)) |
69 | rb.AddDataPackFromPath(ash_test_resources_100, ui::SCALE_FACTOR_100P); | ||||
70 | if (ui::ResourceBundle::IsScaleFactorSupported(ui::SCALE_FACTOR_200P)) | ||||
71 | rb.AddDataPackFromPath(ash_test_resources_200, ui::SCALE_FACTOR_200P); | ||||
reveman | 2799f7f | 2015-03-16 19:06:21 | [diff] [blame] | 72 | |
reveman | 1af05cb3 | 2015-03-17 23:18:16 | [diff] [blame] | 73 | base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); |
sadrul | 578205fa | 2016-04-11 22:43:56 | [diff] [blame] | 74 | env_ = aura::Env::CreateInstance(); |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 75 | } |
76 | |||||
77 | void AuraShellTestSuite::Shutdown() { | ||||
sadrul | 578205fa | 2016-04-11 22:43:56 | [diff] [blame] | 78 | env_.reset(); |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 79 | ui::ResourceBundle::CleanupSharedInstance(); |
[email protected] | b84f821c | 2013-05-28 17:56:09 | [diff] [blame] | 80 | #if defined(OS_WIN) |
81 | com_initializer_.reset(); | ||||
82 | #endif | ||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 83 | base::TestSuite::Shutdown(); |
84 | } | ||||
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 85 | |
86 | } // namespace test | ||||
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 87 | } // namespace ash |