| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ios/web/public/test/web_test_suite.h" | 5 #include "ios/web/public/test/web_test_suite.h" | 
| 6 | 6 | 
| 7 #include "base/macros.h" |  | 
| 8 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" | 
| 9 #include "base/metrics/statistics_recorder.h" | 8 #include "base/metrics/statistics_recorder.h" | 
| 10 #include "base/path_service.h" | 9 #include "base/path_service.h" | 
| 11 #import "ios/web/public/test/test_web_client.h" | 10 #import "ios/web/public/test/test_web_client.h" | 
| 12 #include "ios/web/public/url_schemes.h" | 11 #include "ios/web/public/url_schemes.h" | 
| 13 #include "ios/web/web_thread_impl.h" |  | 
| 14 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" | 
| 15 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" | 
| 16 | 14 | 
| 17 namespace web { | 15 namespace web { | 
| 18 | 16 | 
| 19 class WebTestSuiteListener : public testing::EmptyTestEventListener { |  | 
| 20  public: |  | 
| 21   WebTestSuiteListener() {} |  | 
| 22   void OnTestEnd(const testing::TestInfo& test_info) override { |  | 
| 23     WebThreadImpl::FlushThreadPoolHelperForTesting(); |  | 
| 24   } |  | 
| 25 |  | 
| 26  private: |  | 
| 27   DISALLOW_COPY_AND_ASSIGN(WebTestSuiteListener); |  | 
| 28 }; |  | 
| 29 |  | 
| 30 WebTestSuite::WebTestSuite(int argc, char** argv) | 17 WebTestSuite::WebTestSuite(int argc, char** argv) | 
| 31     : base::TestSuite(argc, argv), | 18     : base::TestSuite(argc, argv), | 
| 32       web_client_(base::WrapUnique(new TestWebClient)) {} | 19       web_client_(base::WrapUnique(new TestWebClient)) {} | 
| 33 | 20 | 
| 34 WebTestSuite::~WebTestSuite() {} | 21 WebTestSuite::~WebTestSuite() {} | 
| 35 | 22 | 
| 36 void WebTestSuite::Initialize() { | 23 void WebTestSuite::Initialize() { | 
| 37   base::TestSuite::Initialize(); | 24   base::TestSuite::Initialize(); | 
| 38 | 25 | 
| 39   // Initialize the histograms subsystem, so that any histograms hit in tests | 26   // Initialize the histograms subsystem, so that any histograms hit in tests | 
| 40   // are correctly registered with the statistics recorder and can be queried | 27   // are correctly registered with the statistics recorder and can be queried | 
| 41   // by tests. | 28   // by tests. | 
| 42   base::StatisticsRecorder::Initialize(); | 29   base::StatisticsRecorder::Initialize(); | 
| 43 | 30 | 
| 44   testing::UnitTest::GetInstance()->listeners().Append( |  | 
| 45       new WebTestSuiteListener); |  | 
| 46 |  | 
| 47   RegisterWebSchemes(false); | 31   RegisterWebSchemes(false); | 
| 48 | 32 | 
| 49   // Force unittests to run using en-US so if testing string output will work | 33   // Force unittests to run using en-US so if testing string output will work | 
| 50   // regardless of the system language. | 34   // regardless of the system language. | 
| 51   ui::ResourceBundle::InitSharedInstanceWithLocale( | 35   ui::ResourceBundle::InitSharedInstanceWithLocale( | 
| 52       "en-US", nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 36       "en-US", nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 
| 53   base::FilePath resources_pack_path; | 37   base::FilePath resources_pack_path; | 
| 54   base::PathService::Get(base::DIR_MODULE, &resources_pack_path); | 38   base::PathService::Get(base::DIR_MODULE, &resources_pack_path); | 
| 55   resources_pack_path = | 39   resources_pack_path = | 
| 56       resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 40       resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 
| 57   ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 41   ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 
| 58       resources_pack_path, ui::SCALE_FACTOR_NONE); | 42       resources_pack_path, ui::SCALE_FACTOR_NONE); | 
| 59 } | 43 } | 
| 60 | 44 | 
| 61 void WebTestSuite::Shutdown() { | 45 void WebTestSuite::Shutdown() { | 
| 62   ResourceBundle::CleanupSharedInstance(); | 46   ResourceBundle::CleanupSharedInstance(); | 
| 63   base::TestSuite::Shutdown(); | 47   base::TestSuite::Shutdown(); | 
| 64 } | 48 } | 
| 65 | 49 | 
| 66 }  // namespace web | 50 }  // namespace web | 
| OLD | NEW | 
|---|