cast_test_launcher.cc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include "base/command_line.h"
  5. #include "base/system/sys_info.h"
  6. #include "base/test/launcher/test_launcher.h"
  7. #include "base/test/test_suite.h"
  8. #include "build/build_config.h"
  9. #include "chromecast/app/cast_main_delegate.h"
  10. #include "content/public/common/network_service_util.h"
  11. #include "content/public/test/test_launcher.h"
  12. #include "ipc/ipc_channel.h"
  13. #include "mojo/core/embedder/embedder.h"
  14. #if BUILDFLAG(IS_WIN)
  15. #include "base/win/win_util.h"
  16. #endif // BUILDFLAG(IS_WIN)
  17. namespace chromecast {
  18. namespace shell {
  19. class CastTestLauncherDelegate : public content::TestLauncherDelegate {
  20. public:
  21. CastTestLauncherDelegate() {}
  22. CastTestLauncherDelegate(const CastTestLauncherDelegate&) = delete;
  23. CastTestLauncherDelegate& operator=(const CastTestLauncherDelegate&) = delete;
  24. ~CastTestLauncherDelegate() override {}
  25. int RunTestSuite(int argc, char** argv) override {
  26. base::TestSuite test_suite(argc, argv);
  27. // Browser tests are expected not to tear-down various globals .
  28. test_suite.DisableCheckForLeakedGlobals();
  29. return test_suite.Run();
  30. }
  31. protected:
  32. #if !BUILDFLAG(IS_ANDROID)
  33. content::ContentMainDelegate* CreateContentMainDelegate() override {
  34. return new CastMainDelegate();
  35. }
  36. #endif // BUILDFLAG(IS_ANDROID)
  37. };
  38. } // namespace shell
  39. } // namespace chromecast
  40. int main(int argc, char** argv) {
  41. base::CommandLine::Init(argc, argv);
  42. size_t parallel_jobs = base::NumParallelJobs(/*cores_per_job=*/2);
  43. if (parallel_jobs == 0U)
  44. return 1;
  45. #if BUILDFLAG(IS_WIN)
  46. // Load and pin user32.dll to avoid having to load it once tests start while
  47. // on the main thread loop where blocking calls are disallowed.
  48. base::win::PinUser32();
  49. #endif // BUILDFLAG(IS_WIN)
  50. chromecast::shell::CastTestLauncherDelegate launcher_delegate;
  51. mojo::core::Init();
  52. content::ForceInProcessNetworkService(true);
  53. return content::LaunchTests(&launcher_delegate, parallel_jobs, argc, argv);
  54. }