1 // Copyright 2014 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 "base/command_line.h"
6 #include "base/macros.h"
7 #include "base/sys_info.h"
8 #include "chromecast/app/cast_main_delegate.h"
9 #include "chromecast/common/chromecast_switches.h"
10 #include "content/public/common/content_switches.h"
11 #include "content/public/test/content_test_suite_base.h"
12 #include "content/public/test/test_launcher.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 namespace chromecast
{
20 // Duplicate switch to avoid dependency on chromecast/internal.
21 const char kSwitchesAVSettingsUnixSocketPath
[] = "av-settings-unix-socket-path";
23 const char kAvSettingsUnixSocketPath
[] = "/tmp/avsettings";
24 const char kTestTypeBrowser
[] = "browser";
26 class BrowserTestSuite
: public content::ContentTestSuiteBase
{
28 BrowserTestSuite(int argc
, char** argv
)
29 : content::ContentTestSuiteBase(argc
, argv
) {
31 ~BrowserTestSuite() override
{
35 DISALLOW_COPY_AND_ASSIGN(BrowserTestSuite
);
38 class ChromecastTestLauncherDelegate
: public content::TestLauncherDelegate
{
40 ChromecastTestLauncherDelegate() {}
41 ~ChromecastTestLauncherDelegate() override
{}
43 int RunTestSuite(int argc
, char** argv
) override
{
44 return BrowserTestSuite(argc
, argv
).Run();
47 bool AdjustChildProcessCommandLine(
48 base::CommandLine
* command_line
,
49 const base::FilePath
& temp_data_dir
) override
{
50 // TODO(gunsch): handle temp_data_dir
51 command_line
->AppendSwitch(switches::kNoWifi
);
52 command_line
->AppendSwitchASCII(switches::kTestType
, kTestTypeBrowser
);
53 command_line
->AppendSwitchASCII(kSwitchesAVSettingsUnixSocketPath
,
54 kAvSettingsUnixSocketPath
);
59 content::ContentMainDelegate
* CreateContentMainDelegate() override
{
60 return new CastMainDelegate();
64 DISALLOW_COPY_AND_ASSIGN(ChromecastTestLauncherDelegate
);
70 } // namespace chromecast
72 int main(int argc
, char** argv
) {
73 int default_jobs
= std::max(1, base::SysInfo::NumberOfProcessors() / 2);
74 chromecast::shell::ChromecastTestLauncherDelegate launcher_delegate
;
75 return LaunchTests(&launcher_delegate
, default_jobs
, argc
, argv
);