[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 | |||||
sky | ecd78dba | 2017-02-15 21:16:43 | [diff] [blame] | 5 | #include "ash/test/ash_test_suite.h" |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 6 | |
sky | 25b49b28 | 2017-03-31 14:41:13 | [diff] [blame] | 7 | #include "ash/test/ash_test_helper.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 8 | #include "base/files/file_path.h" |
msw | 40ddaa81f | 2016-02-10 00:26:16 | [diff] [blame] | 9 | #include "base/i18n/rtl.h" |
10 | #include "base/path_service.h" | ||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 11 | #include "build/build_config.h" |
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 12 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 13 | #include "ui/base/resource/resource_bundle.h" |
14 | #include "ui/base/ui_base_paths.h" | ||||
Sadrul Habib Chowdhury | eeb5a94 | 2017-11-28 21:17:23 | [diff] [blame] | 15 | #include "ui/base/ui_base_switches.h" |
Mitsuru Oshima | f5025cc7 | 2021-10-07 10:28:18 | [diff] [blame^] | 16 | #include "ui/display/display_switches.h" |
Scott Violet | 40bc90f | 2018-08-07 16:32:14 | [diff] [blame] | 17 | #include "ui/gl/gl_switches.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] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 20 | namespace ash { |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 21 | |
sky | ecd78dba | 2017-02-15 21:16:43 | [diff] [blame] | 22 | AshTestSuite::AshTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} |
thakis | 94b3605 | 2015-04-30 20:07:48 | [diff] [blame] | 23 | |
Chris Watkins | c24daf6 | 2017-11-28 03:43:09 | [diff] [blame] | 24 | AshTestSuite::~AshTestSuite() = default; |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 25 | |
sky | ecd78dba | 2017-02-15 21:16:43 | [diff] [blame] | 26 | void AshTestSuite::Initialize() { |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 27 | base::TestSuite::Initialize(); |
Scott Violet | 40bc90f | 2018-08-07 16:32:14 | [diff] [blame] | 28 | |
29 | // Force software-gl. This is necessary for tests that trigger launching ash | ||||
30 | // in its own process | ||||
31 | base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | ||||
32 | cmd_line->AppendSwitch(switches::kOverrideUseSoftwareGLForTests); | ||||
Mitsuru Oshima | f5025cc7 | 2021-10-07 10:28:18 | [diff] [blame^] | 33 | cmd_line->AppendSwitch(switches::kRejectSquareDisplay); |
Scott Violet | 40bc90f | 2018-08-07 16:32:14 | [diff] [blame] | 34 | |
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] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 37 | ui::RegisterPathProvider(); |
38 | |||||
msw | 40ddaa81f | 2016-02-10 00:26:16 | [diff] [blame] | 39 | // Force unittests to run using en-US so if we test against string output, |
40 | // it'll pass regardless of the system language. | ||||
41 | base::i18n::SetICUDefaultLocale("en_US"); | ||||
42 | |||||
msw | d04d3ef3 | 2016-07-18 23:43:08 | [diff] [blame] | 43 | // Load ash test resources and en-US strings; not 'common' (Chrome) resources. |
msw | 40ddaa81f | 2016-02-10 00:26:16 | [diff] [blame] | 44 | base::FilePath path; |
Avi Drissman | ea15ea0 | 2018-05-07 18:55:12 | [diff] [blame] | 45 | base::PathService::Get(base::DIR_MODULE, &path); |
msw | 40ddaa81f | 2016-02-10 00:26:16 | [diff] [blame] | 46 | base::FilePath ash_test_strings = |
47 | path.Append(FILE_PATH_LITERAL("ash_test_strings.pak")); | ||||
msw | 40ddaa81f | 2016-02-10 00:26:16 | [diff] [blame] | 48 | ui::ResourceBundle::InitSharedInstanceWithPakPath(ash_test_strings); |
sky | abc167a | 2016-09-07 00:57:45 | [diff] [blame] | 49 | |
Mitsuru Oshima | 15732bc9 | 2021-08-16 22:59:31 | [diff] [blame] | 50 | if (ui::ResourceBundle::IsScaleFactorSupported(ui::k100Percent)) { |
sky | abc167a | 2016-09-07 00:57:45 | [diff] [blame] | 51 | base::FilePath ash_test_resources_100 = |
Scott Violet | e9d8df754 | 2018-12-18 16:19:03 | [diff] [blame] | 52 | path.AppendASCII("ash_test_resources_100_percent.pak"); |
sky | abc167a | 2016-09-07 00:57:45 | [diff] [blame] | 53 | ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
Mitsuru Oshima | 15732bc9 | 2021-08-16 22:59:31 | [diff] [blame] | 54 | ash_test_resources_100, ui::k100Percent); |
sky | abc167a | 2016-09-07 00:57:45 | [diff] [blame] | 55 | } |
Mitsuru Oshima | 15732bc9 | 2021-08-16 22:59:31 | [diff] [blame] | 56 | if (ui::ResourceBundle::IsScaleFactorSupported(ui::k200Percent)) { |
sky | abc167a | 2016-09-07 00:57:45 | [diff] [blame] | 57 | base::FilePath ash_test_resources_200 = |
58 | path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak")); | ||||
59 | ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | ||||
Mitsuru Oshima | 15732bc9 | 2021-08-16 22:59:31 | [diff] [blame] | 60 | ash_test_resources_200, ui::k200Percent); |
sky | abc167a | 2016-09-07 00:57:45 | [diff] [blame] | 61 | } |
reveman | 2799f7f | 2015-03-16 19:06:21 | [diff] [blame] | 62 | |
reveman | 1af05cb3 | 2015-03-17 23:18:16 | [diff] [blame] | 63 | base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); |
Scott Violet | aad4d1ab | 2019-05-15 21:57:15 | [diff] [blame] | 64 | env_ = aura::Env::CreateInstance(); |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 65 | } |
66 | |||||
sky | ecd78dba | 2017-02-15 21:16:43 | [diff] [blame] | 67 | void AshTestSuite::Shutdown() { |
sadrul | 578205fa | 2016-04-11 22:43:56 | [diff] [blame] | 68 | env_.reset(); |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 69 | ui::ResourceBundle::CleanupSharedInstance(); |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 70 | base::TestSuite::Shutdown(); |
71 | } | ||||
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 72 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 73 | } // namespace ash |