OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/sys_info.h" | 7 #include "base/sys_info.h" |
8 #include "chromecast/app/cast_main_delegate.h" | 8 #include "chromecast/app/cast_main_delegate.h" |
| 9 #include "chromecast/common/chromecast_switches.h" |
9 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
10 #include "content/public/test/content_test_suite_base.h" | 11 #include "content/public/test/content_test_suite_base.h" |
11 #include "content/public/test/test_launcher.h" | 12 #include "content/public/test/test_launcher.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace chromecast { | 15 namespace chromecast { |
15 namespace shell { | 16 namespace shell { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 // Duplicate settings to avoid link dependency on chromecast/internal. | 20 // Duplicate switch to avoid dependency on chromecast/internal. |
20 const char kSwitchesAVSettingsUnixSocketPath[] = "av-settings-unix-socket-path"; | 21 const char kSwitchesAVSettingsUnixSocketPath[] = "av-settings-unix-socket-path"; |
21 const char kSwitchesNoWifi[] = "no-wifi"; | |
22 | 22 |
23 const char kAvSettingsUnixSocketPath[] = "/tmp/avsettings"; | 23 const char kAvSettingsUnixSocketPath[] = "/tmp/avsettings"; |
24 const char kTestTypeBrowser[] = "browser"; | 24 const char kTestTypeBrowser[] = "browser"; |
25 | 25 |
26 class BrowserTestSuite : public content::ContentTestSuiteBase { | 26 class BrowserTestSuite : public content::ContentTestSuiteBase { |
27 public: | 27 public: |
28 BrowserTestSuite(int argc, char** argv) | 28 BrowserTestSuite(int argc, char** argv) |
29 : content::ContentTestSuiteBase(argc, argv) { | 29 : content::ContentTestSuiteBase(argc, argv) { |
30 } | 30 } |
31 ~BrowserTestSuite() override { | 31 ~BrowserTestSuite() override { |
32 } | 32 } |
33 | 33 |
34 private: | 34 private: |
35 DISALLOW_COPY_AND_ASSIGN(BrowserTestSuite); | 35 DISALLOW_COPY_AND_ASSIGN(BrowserTestSuite); |
36 }; | 36 }; |
37 | 37 |
38 class ChromecastTestLauncherDelegate : public content::TestLauncherDelegate { | 38 class ChromecastTestLauncherDelegate : public content::TestLauncherDelegate { |
39 public: | 39 public: |
40 ChromecastTestLauncherDelegate() {} | 40 ChromecastTestLauncherDelegate() {} |
41 ~ChromecastTestLauncherDelegate() override {} | 41 ~ChromecastTestLauncherDelegate() override {} |
42 | 42 |
43 int RunTestSuite(int argc, char** argv) override { | 43 int RunTestSuite(int argc, char** argv) override { |
44 return BrowserTestSuite(argc, argv).Run(); | 44 return BrowserTestSuite(argc, argv).Run(); |
45 } | 45 } |
46 | 46 |
47 bool AdjustChildProcessCommandLine( | 47 bool AdjustChildProcessCommandLine( |
48 base::CommandLine* command_line, | 48 base::CommandLine* command_line, |
49 const base::FilePath& temp_data_dir) override { | 49 const base::FilePath& temp_data_dir) override { |
50 // TODO(gunsch): handle temp_data_dir | 50 // TODO(gunsch): handle temp_data_dir |
51 command_line->AppendSwitch(kSwitchesNoWifi); | 51 command_line->AppendSwitch(switches::kNoWifi); |
52 command_line->AppendSwitchASCII(switches::kTestType, kTestTypeBrowser); | 52 command_line->AppendSwitchASCII(switches::kTestType, kTestTypeBrowser); |
53 command_line->AppendSwitchASCII(kSwitchesAVSettingsUnixSocketPath, | 53 command_line->AppendSwitchASCII(kSwitchesAVSettingsUnixSocketPath, |
54 kAvSettingsUnixSocketPath); | 54 kAvSettingsUnixSocketPath); |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 protected: | 58 protected: |
59 content::ContentMainDelegate* CreateContentMainDelegate() override { | 59 content::ContentMainDelegate* CreateContentMainDelegate() override { |
60 return new CastMainDelegate(); | 60 return new CastMainDelegate(); |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 DISALLOW_COPY_AND_ASSIGN(ChromecastTestLauncherDelegate); | 64 DISALLOW_COPY_AND_ASSIGN(ChromecastTestLauncherDelegate); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 } // namespace shell | 69 } // namespace shell |
70 } // namespace chromecast | 70 } // namespace chromecast |
71 | 71 |
72 int main(int argc, char** argv) { | 72 int main(int argc, char** argv) { |
73 int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2); | 73 int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2); |
74 chromecast::shell::ChromecastTestLauncherDelegate launcher_delegate; | 74 chromecast::shell::ChromecastTestLauncherDelegate launcher_delegate; |
75 return LaunchTests(&launcher_delegate, default_jobs, argc, argv); | 75 return LaunchTests(&launcher_delegate, default_jobs, argc, argv); |
76 } | 76 } |
OLD | NEW |