OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/bind.h" |
| 6 #include "base/macros.h" |
| 7 #include "base/sys_info.h" |
| 8 #include "content/public/test/content_test_suite_base.h" |
| 9 #include "content/public/test/test_launcher.h" |
| 10 #include "headless/lib/browser/headless_browser_impl.h" |
| 11 #include "headless/lib/headless_content_main_delegate.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 namespace headless { |
| 15 namespace { |
| 16 |
| 17 class HeadlessBrowserImplForTest : public HeadlessBrowserImpl { |
| 18 public: |
| 19 explicit HeadlessBrowserImplForTest(const HeadlessBrowser::Options& options) |
| 20 : HeadlessBrowserImpl(StartCallback(), options) {} |
| 21 |
| 22 private: |
| 23 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserImplForTest); |
| 24 }; |
| 25 |
| 26 class HeadlessTestLauncherDelegate : public content::TestLauncherDelegate { |
| 27 public: |
| 28 HeadlessTestLauncherDelegate() {} |
| 29 ~HeadlessTestLauncherDelegate() override {} |
| 30 |
| 31 // content::TestLauncherDelegate implementation: |
| 32 int RunTestSuite(int argc, char** argv) override { |
| 33 return base::TestSuite(argc, argv).Run(); |
| 34 } |
| 35 |
| 36 bool AdjustChildProcessCommandLine( |
| 37 base::CommandLine* command_line, |
| 38 const base::FilePath& temp_data_dir) override { |
| 39 return true; |
| 40 } |
| 41 |
| 42 protected: |
| 43 content::ContentMainDelegate* CreateContentMainDelegate() override { |
| 44 // TODO(skyostil): Add a way to test custom options. |
| 45 HeadlessBrowser::Options::Builder options_builder(0, nullptr); |
| 46 scoped_ptr<HeadlessBrowserImpl> browser( |
| 47 new HeadlessBrowserImplForTest(options_builder.Build())); |
| 48 return new HeadlessContentMainDelegate(std::move(browser)); |
| 49 } |
| 50 |
| 51 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(HeadlessTestLauncherDelegate); |
| 53 }; |
| 54 |
| 55 } // namespace |
| 56 } // namespace headless |
| 57 |
| 58 int main(int argc, char** argv) { |
| 59 int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2); |
| 60 headless::HeadlessTestLauncherDelegate launcher_delegate; |
| 61 return LaunchTests(&launcher_delegate, default_jobs, argc, argv); |
| 62 } |
OLD | NEW |