Revert of aura: Require explicit ownership of the Env instance. (patchset #7 id:12000...
[chromium-blink-merge.git] / ash / test / test_suite.cc
blobc39c76bdbef4ad251c415bb2d1585bd2a1030ac6
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/test/test_suite.h"
7 #include "ash/ash_switches.h"
8 #include "base/command_line.h"
9 #include "base/files/file_path.h"
10 #include "build/build_config.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/aura/env.h"
13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/base/ui_base_paths.h"
15 #include "ui/gfx/gfx_paths.h"
16 #include "ui/gl/test/gl_surface_test_support.h"
18 #if defined(OS_WIN)
19 #include "base/win/windows_version.h"
20 #include "ui/base/win/atl_module.h"
21 #include "win8/test/metro_registration_helper.h"
22 #include "win8/test/test_registrar_constants.h"
23 #endif
25 namespace ash {
26 namespace test {
28 AuraShellTestSuite::AuraShellTestSuite(int argc, char** argv)
29 : TestSuite(argc, argv) {
32 AuraShellTestSuite::~AuraShellTestSuite() {
35 void AuraShellTestSuite::Initialize() {
36 base::TestSuite::Initialize();
37 gfx::GLSurfaceTestSupport::InitializeOneOff();
39 #if defined(OS_WIN)
40 base::win::Version version = base::win::GetVersion();
41 // Although Ash officially is only supported for users on Win7+, we still run
42 // ash_unittests on Vista builders, so we still need to initialize COM.
43 if (version >= base::win::VERSION_VISTA &&
44 !base::CommandLine::ForCurrentProcess()->HasSwitch(
45 ash::switches::kForceAshToDesktop)) {
46 com_initializer_.reset(new base::win::ScopedCOMInitializer());
47 ui::win::CreateATLModuleIfNeeded();
48 if (version >= base::win::VERSION_WIN8)
49 ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously());
51 #endif
53 gfx::RegisterPathProvider();
54 ui::RegisterPathProvider();
56 // Force unittests to run using en-US so if we test against string
57 // output, it'll pass regardless of the system language.
58 ui::ResourceBundle::InitSharedInstanceWithLocale(
59 "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
61 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_);
62 aura::Env::CreateInstance(true);
65 void AuraShellTestSuite::Shutdown() {
66 aura::Env::DeleteInstance();
67 ui::ResourceBundle::CleanupSharedInstance();
68 #if defined(OS_WIN)
69 com_initializer_.reset();
70 #endif
71 base::TestSuite::Shutdown();
74 } // namespace test
75 } // namespace ash