chromeos_components_test_suite.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2020 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 "chromeos/components/chromeos_components_test_suite.h"
  5. #include "base/base_paths.h"
  6. #include "base/files/file_path.h"
  7. #include "base/i18n/rtl.h"
  8. #include "base/path_service.h"
  9. #include "testing/gtest/include/gtest/gtest.h"
  10. #include "ui/base/resource/resource_bundle.h"
  11. #include "ui/base/ui_base_paths.h"
  12. namespace {
  13. // Initializes the i18n stack and loads the necessary strings. Uses a specific
  14. // locale, so that the tests can compare against golden strings without
  15. // depending on the environment.
  16. void InitI18n() {
  17. base::i18n::SetICUDefaultLocale("en_US");
  18. ui::RegisterPathProvider();
  19. base::FilePath ui_test_pak_path;
  20. ASSERT_TRUE(base::PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
  21. ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
  22. base::FilePath dir_assets_path;
  23. ASSERT_TRUE(base::PathService::Get(base::DIR_ASSETS, &dir_assets_path));
  24. base::FilePath chromeos_test_strings_path =
  25. dir_assets_path.Append(FILE_PATH_LITERAL("chromeos_test_strings.pak"));
  26. ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
  27. chromeos_test_strings_path, ui::kScaleFactorNone);
  28. }
  29. } // namespace
  30. ChromeosComponentsTestSuite::ChromeosComponentsTestSuite(int argc, char** argv)
  31. : TestSuite(argc, argv) {}
  32. ChromeosComponentsTestSuite::~ChromeosComponentsTestSuite() = default;
  33. void ChromeosComponentsTestSuite::Initialize() {
  34. base::TestSuite::Initialize();
  35. InitI18n();
  36. }
  37. void ChromeosComponentsTestSuite::Shutdown() {
  38. ui::ResourceBundle::CleanupSharedInstance();
  39. base::TestSuite::Shutdown();
  40. }