[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 | |
[email protected] | e9a3b0cf | 2013-03-25 20:23:41 | [diff] [blame] | 7 | #include "ash/ash_switches.h" |
8 | #include "base/command_line.h" | ||||
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 9 | #include "base/files/file_path.h" |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 10 | #include "build/build_config.h" |
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 11 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 12 | #include "ui/base/resource/resource_bundle.h" |
13 | #include "ui/base/ui_base_paths.h" | ||||
14 | #include "ui/gfx/gfx_paths.h" | ||||
[email protected] | 698bdb6 | 2014-02-22 08:14:55 | [diff] [blame] | 15 | #include "ui/gl/gl_surface.h" |
[email protected] | 72f08de | 2011-12-09 16:19:03 | [diff] [blame] | 16 | |
[email protected] | 1c3f700 | 2013-01-21 18:46:05 | [diff] [blame] | 17 | #if defined(OS_WIN) |
18 | #include "base/win/windows_version.h" | ||||
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 19 | #include "ui/base/win/atl_module.h" |
20 | #include "win8/test/metro_registration_helper.h" | ||||
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 21 | #include "win8/test/test_registrar_constants.h" |
[email protected] | 1c3f700 | 2013-01-21 18:46:05 | [diff] [blame] | 22 | #endif |
23 | |||||
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 24 | namespace ash { |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 25 | namespace test { |
26 | |||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 27 | AuraShellTestSuite::AuraShellTestSuite(int argc, char** argv) |
28 | : TestSuite(argc, argv) {} | ||||
29 | |||||
30 | void AuraShellTestSuite::Initialize() { | ||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 31 | base::TestSuite::Initialize(); |
[email protected] | f14a8a4 | 2014-03-04 21:52:17 | [diff] [blame] | 32 | gfx::GLSurface::InitializeOneOffForTests(); |
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 33 | |
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 34 | #if defined(OS_WIN) |
[email protected] | cb1782c2 | 2014-03-12 19:44:05 | [diff] [blame] | 35 | base::win::Version version = base::win::GetVersion(); |
36 | // Although Ash officially is only supported for users on Win7+, we still run | ||||
37 | // ash_unittests on Vista builders, so we still need to initialize COM. | ||||
38 | if (version >= base::win::VERSION_VISTA && | ||||
pgal.u-szeged | d84534d3 | 2014-10-29 12:34:30 | [diff] [blame] | 39 | !base::CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | e9a3b0cf | 2013-03-25 20:23:41 | [diff] [blame] | 40 | ash::switches::kForceAshToDesktop)) { |
[email protected] | b84f821c | 2013-05-28 17:56:09 | [diff] [blame] | 41 | com_initializer_.reset(new base::win::ScopedCOMInitializer()); |
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 42 | ui::win::CreateATLModuleIfNeeded(); |
[email protected] | cb1782c2 | 2014-03-12 19:44:05 | [diff] [blame] | 43 | if (version >= base::win::VERSION_WIN8) |
44 | ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously()); | ||||
[email protected] | 41168e2 | 2013-02-13 18:25:43 | [diff] [blame] | 45 | } |
46 | #endif | ||||
47 | |||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 48 | gfx::RegisterPathProvider(); |
49 | ui::RegisterPathProvider(); | ||||
50 | |||||
51 | // Force unittests to run using en-US so if we test against string | ||||
52 | // output, it'll pass regardless of the system language. | ||||
[email protected] | 4ce2aa6 | 2014-08-14 01:05:49 | [diff] [blame] | 53 | ui::ResourceBundle::InitSharedInstanceWithLocale( |
54 | "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | ||||
reveman | 2799f7f | 2015-03-16 19:06:21 | [diff] [blame] | 55 | |
56 | base::DiscardableMemoryShmemAllocator::SetInstance( | ||||
57 | &discardable_memory_allocator_); | ||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 58 | } |
59 | |||||
60 | void AuraShellTestSuite::Shutdown() { | ||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 61 | ui::ResourceBundle::CleanupSharedInstance(); |
[email protected] | b84f821c | 2013-05-28 17:56:09 | [diff] [blame] | 62 | #if defined(OS_WIN) |
63 | com_initializer_.reset(); | ||||
64 | #endif | ||||
[email protected] | 2b99f8c | 2011-10-11 19:42:24 | [diff] [blame] | 65 | base::TestSuite::Shutdown(); |
66 | } | ||||
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 67 | |
68 | } // namespace test | ||||
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 69 | } // namespace ash |