test_suite.cc revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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. 4 5#include "ash/test/test_suite.h" 6 7#include "ash/ash_switches.h" 8#include "base/command_line.h" 9#include "base/files/file_path.h" 10#include "base/path_service.h" 11#include "build/build_config.h" 12#include "testing/gtest/include/gtest/gtest.h" 13#include "ui/base/resource/resource_bundle.h" 14#include "ui/base/ui_base_paths.h" 15#include "ui/compositor/compositor_setup.h" 16#include "ui/compositor/test/compositor_test_support.h" 17#include "ui/gfx/gfx_paths.h" 18 19#if defined(OS_MACOSX) 20#include "ash/test/test_suite_init.h" 21#endif 22 23#if defined(OS_WIN) 24#include "base/win/windows_version.h" 25#include "ui/base/win/atl_module.h" 26#include "win8/test/metro_registration_helper.h" 27#include "win8/test/test_registrar_constants.h" 28#endif 29 30namespace ash { 31namespace test { 32 33AuraShellTestSuite::AuraShellTestSuite(int argc, char** argv) 34 : TestSuite(argc, argv) {} 35 36void AuraShellTestSuite::Initialize() { 37 base::TestSuite::Initialize(); 38 39#if defined(OS_WIN) 40 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && 41 !CommandLine::ForCurrentProcess()->HasSwitch( 42 ash::switches::kForceAshToDesktop)) { 43 com_initializer_.reset(new base::win::ScopedCOMInitializer()); 44 ui::win::CreateATLModuleIfNeeded(); 45 ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously()); 46 } 47#endif 48 49 gfx::RegisterPathProvider(); 50 ui::RegisterPathProvider(); 51 52#if defined(OS_MACOSX) 53 ash::test::OverrideFrameworkBundle(); 54#endif 55 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("en-US", NULL); 59 ui::CompositorTestSupport::Initialize(); 60 ui::SetupTestCompositor(); 61} 62 63void AuraShellTestSuite::Shutdown() { 64 ui::CompositorTestSupport::Terminate(); 65 ui::ResourceBundle::CleanupSharedInstance(); 66#if defined(OS_WIN) 67 com_initializer_.reset(); 68#endif 69 base::TestSuite::Shutdown(); 70} 71 72} // namespace test 73} // namespace ash 74