Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: headless/test/headless_test_launcher.cc

Issue 1674263002: headless: Initial headless embedder API implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix shutdown memory leak. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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(base::Bind(&HeadlessBrowserImplForTest::OnStart,
21 base::Unretained(this)),
22 options) {}
23
24 void OnStart(HeadlessBrowser* browser) { DCHECK(browser == this); }
Ryan Sleevi 2016/02/25 22:04:37 You should never DCHECK in tests.
Sami 2016/02/26 18:49:16 Changed into EXPECT_EQ.
25
26 private:
27 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserImplForTest);
28 };
29
30 class HeadlessTestLauncherDelegate : public content::TestLauncherDelegate {
31 public:
32 HeadlessTestLauncherDelegate() {}
33 ~HeadlessTestLauncherDelegate() override {}
34
35 // content::TestLauncherDelegate implementation:
36 int RunTestSuite(int argc, char** argv) override {
37 return base::TestSuite(argc, argv).Run();
38 }
39
40 bool AdjustChildProcessCommandLine(
41 base::CommandLine* command_line,
42 const base::FilePath& temp_data_dir) override {
43 return true;
44 }
45
46 protected:
47 content::ContentMainDelegate* CreateContentMainDelegate() override {
48 // TODO(skyostil): Add a way to test custom options.
49 HeadlessBrowser::Options::Builder options_builder(0, nullptr);
50 scoped_ptr<HeadlessBrowserImpl> browser(
51 new HeadlessBrowserImplForTest(options_builder.Build()));
52 return new HeadlessContentMainDelegate(std::move(browser));
53 }
54
55 private:
56 DISALLOW_COPY_AND_ASSIGN(HeadlessTestLauncherDelegate);
57 };
58
59 } // namespace
60 } // namespace headless
61
62 int main(int argc, char** argv) {
63 int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2);
64 headless::HeadlessTestLauncherDelegate launcher_delegate;
65 return LaunchTests(&launcher_delegate, default_jobs, argc, argv);
66 }
OLDNEW
« headless/test/headless_browser_test.cc ('K') | « headless/test/headless_browser_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698