| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" |
| 9 #include "chrome/common/chrome_switches.h" |
| 5 #include "chrome/test/base/chrome_test_launcher.h" | 10 #include "chrome/test/base/chrome_test_launcher.h" |
| 6 | |
| 7 #include "build/build_config.h" | |
| 8 #include "chrome/test/base/chrome_test_suite.h" | 11 #include "chrome/test/base/chrome_test_suite.h" |
| 9 #include "ui/base/test/ui_controls.h" | 12 #include "ui/base/test/ui_controls.h" |
| 13 #include "ui/compositor/compositor_switches.h" |
| 10 | 14 |
| 11 #if defined(USE_AURA) | 15 #if defined(USE_AURA) |
| 12 #include "ui/aura/test/ui_controls_factory_aura.h" | 16 #include "ui/aura/test/ui_controls_factory_aura.h" |
| 13 #include "ui/base/test/ui_controls_aura.h" | 17 #include "ui/base/test/ui_controls_aura.h" |
| 14 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 18 #if defined(OS_LINUX) |
| 15 #include "ui/views/test/ui_controls_factory_desktop_aurax11.h" | 19 #include "ui/views/test/ui_controls_factory_desktop_aurax11.h" |
| 16 #endif | 20 #endif |
| 17 #endif | 21 #endif |
| 18 | 22 |
| 19 #if defined(OS_CHROMEOS) | 23 #if defined(OS_WIN) |
| 20 #include "ash/test/ui_controls_factory_ash.h" | 24 #include "base/win/scoped_com_initializer.h" |
| 21 #endif | 25 #endif |
| 22 | 26 |
| 23 #if defined(OS_WIN) | 27 class PerformanceInteractiveUITestSuite : public ChromeTestSuite { |
| 24 #include "base/win/scoped_com_initializer.h" | |
| 25 #include "chrome/test/base/always_on_top_window_killer_win.h" | |
| 26 #endif | |
| 27 | |
| 28 class InteractiveUITestSuite : public ChromeTestSuite { | |
| 29 public: | 28 public: |
| 30 InteractiveUITestSuite(int argc, char** argv) : ChromeTestSuite(argc, argv) {} | 29 PerformanceInteractiveUITestSuite(int argc, char** argv) |
| 31 ~InteractiveUITestSuite() override {} | 30 : ChromeTestSuite(argc, argv) {} |
| 31 ~PerformanceInteractiveUITestSuite() override {} |
| 32 | 32 |
| 33 protected: | 33 protected: |
| 34 // ChromeTestSuite overrides: | 34 // ChromeTestSuite overrides: |
| 35 void Initialize() override { | 35 void Initialize() override { |
| 36 ChromeTestSuite::Initialize(); | 36 ChromeTestSuite::Initialize(); |
| 37 | 37 |
| 38 // Only allow ui_controls to be used in interactive_ui_tests, since they | 38 // Only allow ui_controls to be used in performance_interactive_ui_tests, |
| 39 // depend on focus and can't be sharded. | 39 // since they depend on focus and can't be sharded. |
| 40 ui_controls::EnableUIControls(); | 40 ui_controls::EnableUIControls(); |
| 41 | 41 |
| 42 #if defined(OS_CHROMEOS) | 42 #if defined(USE_AURA) |
| 43 ui_controls::InstallUIControlsAura(ash::test::CreateAshUIControls()); | |
| 44 #elif defined(USE_AURA) | |
| 45 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
| 46 com_initializer_.reset(new base::win::ScopedCOMInitializer()); | 44 com_initializer_.reset(new base::win::ScopedCOMInitializer()); |
| 47 #endif | 45 #endif |
| 48 | 46 |
| 49 #if defined(OS_LINUX) | 47 #if defined(OS_LINUX) |
| 50 ui_controls::InstallUIControlsAura( | 48 ui_controls::InstallUIControlsAura( |
| 51 views::test::CreateUIControlsDesktopAura()); | 49 views::test::CreateUIControlsDesktopAura()); |
| 52 #else | 50 #else |
| 53 // TODO(win_ash): when running interactive_ui_tests for Win Ash, use above. | 51 // TODO(win_ash): when running performance_interactive_ui_tests |
| 52 // for Win Ash, use above. |
| 54 ui_controls::InstallUIControlsAura(aura::test::CreateUIControlsAura(NULL)); | 53 ui_controls::InstallUIControlsAura(aura::test::CreateUIControlsAura(NULL)); |
| 55 #endif | 54 #endif |
| 56 #endif | 55 #endif |
| 56 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 57 DCHECK(cmd); |
| 58 // Enable pixel output for performance tests. |
| 59 cmd->AppendSwitch(switches::kEnablePixelOutputInTests); |
| 57 } | 60 } |
| 58 | 61 |
| 59 void Shutdown() override { | 62 void Shutdown() override { |
| 60 #if defined(OS_WIN) | 63 #if defined(OS_WIN) |
| 61 com_initializer_.reset(); | 64 com_initializer_.reset(); |
| 62 #endif | 65 #endif |
| 63 } | 66 } |
| 64 | 67 |
| 65 private: | 68 private: |
| 66 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
| 67 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_; | 70 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_; |
| 68 #endif | 71 #endif |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 class InteractiveUITestSuiteRunner : public ChromeTestSuiteRunner { | 74 class PerformanceInteractiveUITestSuiteRunner : public ChromeTestSuiteRunner { |
| 72 public: | 75 public: |
| 73 int RunTestSuite(int argc, char** argv) override { | 76 int RunTestSuite(int argc, char** argv) override { |
| 74 return InteractiveUITestSuite(argc, argv).Run(); | 77 return PerformanceInteractiveUITestSuite(argc, argv).Run(); |
| 75 } | 78 } |
| 76 }; | 79 }; |
| 77 | 80 |
| 78 int main(int argc, char** argv) { | 81 int main(int argc, char** argv) { |
| 79 #if defined(OS_WIN) | 82 // Run performance_interactive_ui_tests serially, |
| 80 KillAlwaysOnTopWindows(RunType::BEFORE_TEST); | 83 // they do not support running in parallel. |
| 81 #endif | |
| 82 // Run interactive_ui_tests serially, they do not support running in parallel. | |
| 83 int default_jobs = 1; | 84 int default_jobs = 1; |
| 84 InteractiveUITestSuiteRunner runner; | 85 PerformanceInteractiveUITestSuiteRunner runner; |
| 85 ChromeTestLauncherDelegate delegate(&runner); | 86 ChromeTestLauncherDelegate delegate(&runner); |
| 86 const int result = LaunchChromeTests(default_jobs, &delegate, argc, argv); | 87 return LaunchChromeTests(default_jobs, &delegate, argc, argv); |
| 87 #if defined(OS_WIN) | |
| 88 KillAlwaysOnTopWindows(RunType::AFTER_TEST); | |
| 89 #endif | |
| 90 return result; | |
| 91 } | 88 } |
| OLD | NEW |