blob: 93ed86a3608c17f6e8443083fed032b639056691 [file] [log] [blame]
[email protected]578c81b2012-01-27 07:25:021// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]2b99f8c2011-10-11 19:42:242// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
skyecd78dba2017-02-15 21:16:435#include "ash/test/ash_test_suite.h"
[email protected]2b99f8c2011-10-11 19:42:246
sky25b49b282017-03-31 14:41:137#include "ash/test/ash_test_helper.h"
[email protected]57999812013-02-24 05:40:528#include "base/files/file_path.h"
msw40ddaa81f2016-02-10 00:26:169#include "base/i18n/rtl.h"
10#include "base/path_service.h"
[email protected]2b99f8c2011-10-11 19:42:2411#include "build/build_config.h"
[email protected]41168e22013-02-13 18:25:4312#include "testing/gtest/include/gtest/gtest.h"
[email protected]2b99f8c2011-10-11 19:42:2413#include "ui/base/resource/resource_bundle.h"
14#include "ui/base/ui_base_paths.h"
Sadrul Habib Chowdhuryeeb5a942017-11-28 21:17:2315#include "ui/base/ui_base_switches.h"
Mitsuru Oshimaf5025cc72021-10-07 10:28:1816#include "ui/display/display_switches.h"
Scott Violet40bc90f2018-08-07 16:32:1417#include "ui/gl/gl_switches.h"
sadrulba162cd2015-07-20 22:34:2618#include "ui/gl/test/gl_surface_test_support.h"
[email protected]72f08de2011-12-09 16:19:0319
[email protected]55f593352011-12-24 05:42:4620namespace ash {
[email protected]6377a002011-11-10 20:26:4721
skyecd78dba2017-02-15 21:16:4322AshTestSuite::AshTestSuite(int argc, char** argv) : TestSuite(argc, argv) {}
thakis94b36052015-04-30 20:07:4823
Chris Watkinsc24daf62017-11-28 03:43:0924AshTestSuite::~AshTestSuite() = default;
[email protected]2b99f8c2011-10-11 19:42:2425
skyecd78dba2017-02-15 21:16:4326void AshTestSuite::Initialize() {
[email protected]2b99f8c2011-10-11 19:42:2427 base::TestSuite::Initialize();
Scott Violet40bc90f2018-08-07 16:32:1428
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 Oshimaf5025cc72021-10-07 10:28:1833 cmd_line->AppendSwitch(switches::kRejectSquareDisplay);
Scott Violet40bc90f2018-08-07 16:32:1434
kylechar7a463842016-05-26 14:46:1235 gl::GLSurfaceTestSupport::InitializeOneOff();
[email protected]2b99f8c2011-10-11 19:42:2436
[email protected]2b99f8c2011-10-11 19:42:2437 ui::RegisterPathProvider();
38
msw40ddaa81f2016-02-10 00:26:1639 // 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
mswd04d3ef32016-07-18 23:43:0843 // Load ash test resources and en-US strings; not 'common' (Chrome) resources.
msw40ddaa81f2016-02-10 00:26:1644 base::FilePath path;
Avi Drissmanea15ea02018-05-07 18:55:1245 base::PathService::Get(base::DIR_MODULE, &path);
msw40ddaa81f2016-02-10 00:26:1646 base::FilePath ash_test_strings =
47 path.Append(FILE_PATH_LITERAL("ash_test_strings.pak"));
msw40ddaa81f2016-02-10 00:26:1648 ui::ResourceBundle::InitSharedInstanceWithPakPath(ash_test_strings);
skyabc167a2016-09-07 00:57:4549
Mitsuru Oshima15732bc92021-08-16 22:59:3150 if (ui::ResourceBundle::IsScaleFactorSupported(ui::k100Percent)) {
skyabc167a2016-09-07 00:57:4551 base::FilePath ash_test_resources_100 =
Scott Violete9d8df7542018-12-18 16:19:0352 path.AppendASCII("ash_test_resources_100_percent.pak");
skyabc167a2016-09-07 00:57:4553 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
Mitsuru Oshima15732bc92021-08-16 22:59:3154 ash_test_resources_100, ui::k100Percent);
skyabc167a2016-09-07 00:57:4555 }
Mitsuru Oshima15732bc92021-08-16 22:59:3156 if (ui::ResourceBundle::IsScaleFactorSupported(ui::k200Percent)) {
skyabc167a2016-09-07 00:57:4557 base::FilePath ash_test_resources_200 =
58 path.Append(FILE_PATH_LITERAL("ash_test_resources_200_percent.pak"));
59 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
Mitsuru Oshima15732bc92021-08-16 22:59:3160 ash_test_resources_200, ui::k200Percent);
skyabc167a2016-09-07 00:57:4561 }
reveman2799f7f2015-03-16 19:06:2162
reveman1af05cb32015-03-17 23:18:1663 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_);
Scott Violetaad4d1ab2019-05-15 21:57:1564 env_ = aura::Env::CreateInstance();
[email protected]2b99f8c2011-10-11 19:42:2465}
66
skyecd78dba2017-02-15 21:16:4367void AshTestSuite::Shutdown() {
sadrul578205fa2016-04-11 22:43:5668 env_.reset();
[email protected]2b99f8c2011-10-11 19:42:2469 ui::ResourceBundle::CleanupSharedInstance();
[email protected]2b99f8c2011-10-11 19:42:2470 base::TestSuite::Shutdown();
71}
[email protected]6377a002011-11-10 20:26:4772
[email protected]55f593352011-12-24 05:42:4673} // namespace ash