blob: eb28d27c0eafbfe9185a2c24def12972e519a585 [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
[email protected]2f744282011-12-23 22:40:525#include "ash/test/test_suite.h"
[email protected]2b99f8c2011-10-11 19:42:246
mswd9b1b342016-06-17 20:19:577#include "ash/common/ash_switches.h"
[email protected]e9a3b0cf2013-03-25 20:23:418#include "base/command_line.h"
[email protected]57999812013-02-24 05:40:529#include "base/files/file_path.h"
msw40ddaa81f2016-02-10 00:26:1610#include "base/i18n/rtl.h"
11#include "base/path_service.h"
[email protected]2b99f8c2011-10-11 19:42:2412#include "build/build_config.h"
[email protected]41168e22013-02-13 18:25:4313#include "testing/gtest/include/gtest/gtest.h"
sadrul679eb98f2015-08-07 05:25:1014#include "ui/aura/env.h"
[email protected]2b99f8c2011-10-11 19:42:2415#include "ui/base/resource/resource_bundle.h"
16#include "ui/base/ui_base_paths.h"
17#include "ui/gfx/gfx_paths.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]1c3f7002013-01-21 18:46:0520#if defined(OS_WIN)
21#include "base/win/windows_version.h"
[email protected]41168e22013-02-13 18:25:4322#include "ui/base/win/atl_module.h"
[email protected]1c3f7002013-01-21 18:46:0523#endif
24
[email protected]55f593352011-12-24 05:42:4625namespace ash {
[email protected]6377a002011-11-10 20:26:4726namespace test {
27
[email protected]2b99f8c2011-10-11 19:42:2428AuraShellTestSuite::AuraShellTestSuite(int argc, char** argv)
jamescookb8dcef522016-06-25 14:42:5529 : TestSuite(argc, argv) {}
thakis94b36052015-04-30 20:07:4830
jamescookb8dcef522016-06-25 14:42:5531AuraShellTestSuite::~AuraShellTestSuite() {}
[email protected]2b99f8c2011-10-11 19:42:2432
33void AuraShellTestSuite::Initialize() {
[email protected]2b99f8c2011-10-11 19:42:2434 base::TestSuite::Initialize();
kylechar7a463842016-05-26 14:46:1235 gl::GLSurfaceTestSupport::InitializeOneOff();
[email protected]2b99f8c2011-10-11 19:42:2436
[email protected]41168e22013-02-13 18:25:4337#if defined(OS_WIN)
[email protected]cb1782c22014-03-12 19:44:0538 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-szegedd84534d32014-10-29 12:34:3042 !base::CommandLine::ForCurrentProcess()->HasSwitch(
[email protected]e9a3b0cf2013-03-25 20:23:4143 ash::switches::kForceAshToDesktop)) {
[email protected]b84f821c2013-05-28 17:56:0944 com_initializer_.reset(new base::win::ScopedCOMInitializer());
[email protected]41168e22013-02-13 18:25:4345 ui::win::CreateATLModuleIfNeeded();
[email protected]41168e22013-02-13 18:25:4346 }
47#endif
48
[email protected]2b99f8c2011-10-11 19:42:2449 gfx::RegisterPathProvider();
50 ui::RegisterPathProvider();
51
msw40ddaa81f2016-02-10 00:26:1652 // 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
mswd04d3ef32016-07-18 23:43:0856 // Load ash test resources and en-US strings; not 'common' (Chrome) resources.
msw40ddaa81f2016-02-10 00:26:1657 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();
mswd04d3ef32016-07-18 23:43:0868 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);
reveman2799f7f2015-03-16 19:06:2172
reveman1af05cb32015-03-17 23:18:1673 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_);
sadrul578205fa2016-04-11 22:43:5674 env_ = aura::Env::CreateInstance();
[email protected]2b99f8c2011-10-11 19:42:2475}
76
77void AuraShellTestSuite::Shutdown() {
sadrul578205fa2016-04-11 22:43:5678 env_.reset();
[email protected]2b99f8c2011-10-11 19:42:2479 ui::ResourceBundle::CleanupSharedInstance();
[email protected]b84f821c2013-05-28 17:56:0980#if defined(OS_WIN)
81 com_initializer_.reset();
82#endif
[email protected]2b99f8c2011-10-11 19:42:2483 base::TestSuite::Shutdown();
84}
[email protected]6377a002011-11-10 20:26:4785
86} // namespace test
[email protected]55f593352011-12-24 05:42:4687} // namespace ash