run_all_tests.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2015 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/bind.h"
  5. #include "base/command_line.h"
  6. #include "base/feature_list.h"
  7. #include "base/message_loop/message_pump_type.h"
  8. #include "base/task/single_thread_task_executor.h"
  9. #include "base/test/launcher/unit_test_launcher.h"
  10. #include "base/test/test_suite.h"
  11. #include "build/build_config.h"
  12. #include "ui/gl/init/gl_factory.h"
  13. #if defined(USE_OZONE)
  14. #include "ui/ozone/public/ozone_platform.h"
  15. #endif
  16. static int RunHelper(base::TestSuite* test_suite) {
  17. base::FeatureList::InitializeInstance(std::string(), std::string());
  18. std::unique_ptr<base::SingleThreadTaskExecutor> executor;
  19. #if defined(USE_OZONE)
  20. executor = std::make_unique<base::SingleThreadTaskExecutor>(
  21. base::MessagePumpType::UI);
  22. ui::OzonePlatform::InitParams params;
  23. params.single_process = true;
  24. ui::OzonePlatform::InitializeForGPU(params);
  25. #else
  26. executor = std::make_unique<base::SingleThreadTaskExecutor>(
  27. base::MessagePumpType::IO);
  28. #endif
  29. CHECK(gl::init::InitializeGLOneOff(/*system_device_id=*/0));
  30. return test_suite->Run();
  31. }
  32. int main(int argc, char** argv) {
  33. base::TestSuite test_suite(argc, argv);
  34. base::CommandLine::Init(argc, argv);
  35. // Always run the perf tests serially, to avoid distorting
  36. // perf measurements with randomness resulting from running
  37. // in parallel.
  38. return base::LaunchUnitTestsSerially(
  39. argc, argv, base::BindOnce(&RunHelper, base::Unretained(&test_suite)));
  40. }