1 // Copyright 2013 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 "chrome/test/base/chrome_test_launcher.h"
6
7 #include "chrome/test/base/chrome_test_suite.h"
8 #include "ui/base/test/ui_controls.h"
9
10 #if defined(USE_AURA)
11 #include "ui/aura/test/ui_controls_factory_aura.h"
12 #include "ui/base/test/ui_controls_aura.h"
13 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
14 #include "ui/views/test/ui_controls_factory_desktop_aurax11.h"
15 #endif
16 #endif
17
18 #if defined(OS_CHROMEOS)
19 #include "ash/test/ui_controls_factory_ash.h"
20 #endif
21
22 #if defined(OS_WIN)
23 #include "base/win/scoped_com_initializer.h"
24 #endif
25
26 class InteractiveUITestSuite : public ChromeTestSuite {
27 public:
InteractiveUITestSuite(int argc,char ** argv)28 InteractiveUITestSuite(int argc, char** argv) : ChromeTestSuite(argc, argv) {}
~InteractiveUITestSuite()29 virtual ~InteractiveUITestSuite() {}
30
31 protected:
32 // ChromeTestSuite overrides:
Initialize()33 virtual void Initialize() OVERRIDE {
34 ChromeTestSuite::Initialize();
35
36 // Only allow ui_controls to be used in interactive_ui_tests, since they
37 // depend on focus and can't be sharded.
38 ui_controls::EnableUIControls();
39
40 #if defined(OS_CHROMEOS)
41 ui_controls::InstallUIControlsAura(ash::test::CreateAshUIControls());
42 #elif defined(USE_AURA)
43 #if defined(OS_WIN)
44 com_initializer_.reset(new base::win::ScopedCOMInitializer());
45 #endif
46
47 #if defined(OS_LINUX)
48 ui_controls::InstallUIControlsAura(
49 views::test::CreateUIControlsDesktopAura());
50 #else
51 // TODO(win_ash): when running interactive_ui_tests for Win Ash, use above.
52 ui_controls::InstallUIControlsAura(aura::test::CreateUIControlsAura(NULL));
53 #endif
54 #endif
55 }
56
Shutdown()57 virtual void Shutdown() OVERRIDE {
58 #if defined(OS_WIN)
59 com_initializer_.reset();
60 #endif
61 }
62
63 private:
64 #if defined(OS_WIN)
65 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_;
66 #endif
67 };
68
69 class InteractiveUITestSuiteRunner : public ChromeTestSuiteRunner {
70 public:
RunTestSuite(int argc,char ** argv)71 virtual int RunTestSuite(int argc, char** argv) OVERRIDE {
72 return InteractiveUITestSuite(argc, argv).Run();
73 }
74 };
75
main(int argc,char ** argv)76 int main(int argc, char** argv) {
77 // Run interactive_ui_tests serially, they do not support running in parallel.
78 int default_jobs = 1;
79 InteractiveUITestSuiteRunner runner;
80 return LaunchChromeTests(default_jobs, &runner, argc, argv);
81 }
82