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 "ui/test/test_suite.h"
7 #include "base/files/file_path.h"
8 #include "base/path_service.h"
9 #include "build/build_config.h"
10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/base/resource/resource_handle.h"
12 #include "ui/base/ui_base_paths.h"
13 #include "ui/gfx/gfx_paths.h"
15 #if defined(OS_ANDROID)
16 #include "base/android/jni_android.h"
17 #include "ui/android/ui_jni_registrar.h"
20 #if defined(OS_MACOSX) && !defined(OS_IOS)
21 #include "base/mac/bundle_locations.h"
27 UITestSuite::UITestSuite(int argc
, char** argv
) : base::TestSuite(argc
, argv
) {}
29 void UITestSuite::Initialize() {
30 base::TestSuite::Initialize();
32 #if defined(OS_ANDROID)
33 // Register JNI bindings for android.
34 ui::android::RegisterJni(base::android::AttachCurrentThread());
37 ui::RegisterPathProvider();
38 gfx::RegisterPathProvider();
40 #if defined(OS_MACOSX) && !defined(OS_IOS)
41 // Look in the framework bundle for resources.
42 // TODO(port): make a resource bundle for non-app exes. What's done here
43 // isn't really right because this code needs to depend on chrome_dll
44 // being built. This is inappropriate in app.
46 PathService::Get(base::DIR_EXE
, &path
);
47 #if defined(GOOGLE_CHROME_BUILD)
48 path
= path
.AppendASCII("Google Chrome Framework.framework");
49 #elif defined(CHROMIUM_BUILD)
50 path
= path
.AppendASCII("Chromium Framework.framework");
52 #error Unknown branding
54 base::mac::SetOverrideFrameworkBundlePath(path
);
55 #elif defined(OS_POSIX)
56 base::FilePath pak_dir
;
57 #if defined(OS_ANDROID)
58 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID
, &pak_dir
);
60 PathService::Get(base::DIR_MODULE
, &pak_dir
);
61 pak_dir
= pak_dir
.AppendASCII("ui_unittests_strings");
62 PathService::Override(ui::DIR_LOCALES
, pak_dir
);
63 #endif // defined(OS_ANDROID)
64 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
66 // Force unittests to run using en-US so if we test against string
67 // output, it'll pass regardless of the system language.
68 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL
);
70 #if !defined(OS_MACOSX) && defined(OS_POSIX)
71 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
72 pak_dir
.AppendASCII("chrome_100_percent.pak"),
73 ui::SCALE_FACTOR_100P
);
77 void UITestSuite::Shutdown() {
78 ui::ResourceBundle::CleanupSharedInstance();
80 #if defined(OS_MACOSX) && !defined(OS_IOS)
81 base::mac::SetOverrideFrameworkBundle(NULL
);
83 base::TestSuite::Shutdown();