run_all_unittests.cc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/bind.h"
  5. #include "base/path_service.h"
  6. #include "base/test/launcher/unit_test_launcher.h"
  7. #include "base/test/test_suite.h"
  8. #include "build/build_config.h"
  9. #include "mojo/core/embedder/embedder.h"
  10. #include "ui/base/resource/resource_bundle.h"
  11. #include "ui/base/ui_base_paths.h"
  12. #if BUILDFLAG(IS_APPLE)
  13. #include "base/test/mock_chrome_application_mac.h"
  14. #endif
  15. namespace {
  16. class ShellDialogsTestSuite : public base::TestSuite {
  17. public:
  18. ShellDialogsTestSuite(int argc, char** argv);
  19. ShellDialogsTestSuite(const ShellDialogsTestSuite&) = delete;
  20. ShellDialogsTestSuite& operator=(const ShellDialogsTestSuite&) = delete;
  21. protected:
  22. // base::TestSuite:
  23. void Initialize() override;
  24. void Shutdown() override;
  25. };
  26. ShellDialogsTestSuite::ShellDialogsTestSuite(int argc, char** argv)
  27. : base::TestSuite(argc, argv) {}
  28. void ShellDialogsTestSuite::Initialize() {
  29. base::TestSuite::Initialize();
  30. #if BUILDFLAG(IS_APPLE)
  31. mock_cr_app::RegisterMockCrApp();
  32. #endif
  33. // Setup resource bundle.
  34. ui::RegisterPathProvider();
  35. base::FilePath ui_test_pak_path;
  36. base::PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path);
  37. ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
  38. }
  39. void ShellDialogsTestSuite::Shutdown() {
  40. ui::ResourceBundle::CleanupSharedInstance();
  41. base::TestSuite::Shutdown();
  42. }
  43. } // namespace
  44. int main(int argc, char** argv) {
  45. ShellDialogsTestSuite test_suite(argc, argv);
  46. mojo::core::Init();
  47. return base::LaunchUnitTests(argc, argv,
  48. base::BindOnce(&ShellDialogsTestSuite::Run,
  49. base::Unretained(&test_suite)));
  50. }