| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chrome/test/ios_chrome_unit_test_suite.h" | 5 #include "ios/chrome/test/ios_chrome_unit_test_suite.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/metrics/user_metrics.h" |
| 8 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/test/test_simple_task_runner.h" |
| 9 #include "components/content_settings/core/common/content_settings_pattern.h" | 11 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 10 #include "ios/chrome/browser/browser_state/browser_state_keyed_service_factories
.h" | 12 #include "ios/chrome/browser/browser_state/browser_state_keyed_service_factories
.h" |
| 11 #include "ios/chrome/browser/chrome_paths.h" | 13 #include "ios/chrome/browser/chrome_paths.h" |
| 12 #include "ios/chrome/browser/chrome_url_constants.h" | 14 #include "ios/chrome/browser/chrome_url_constants.h" |
| 13 #include "ios/chrome/test/testing_application_context.h" | 15 #include "ios/chrome/test/testing_application_context.h" |
| 14 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 16 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 15 #include "ios/public/provider/chrome/browser/test_chrome_provider_initializer.h" | 17 #include "ios/public/provider/chrome/browser/test_chrome_provider_initializer.h" |
| 16 #include "ios/web/public/web_client.h" | 18 #include "ios/web/public/web_client.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 48 std::unique_ptr<ios::TestChromeProviderInitializer> | 50 std::unique_ptr<ios::TestChromeProviderInitializer> |
| 49 test_ios_chrome_provider_initializer_; | 51 test_ios_chrome_provider_initializer_; |
| 50 std::unique_ptr<ApplicationContext> application_context_; | 52 std::unique_ptr<ApplicationContext> application_context_; |
| 51 | 53 |
| 52 DISALLOW_COPY_AND_ASSIGN(IOSChromeUnitTestSuiteInitializer); | 54 DISALLOW_COPY_AND_ASSIGN(IOSChromeUnitTestSuiteInitializer); |
| 53 }; | 55 }; |
| 54 | 56 |
| 55 } // namespace | 57 } // namespace |
| 56 | 58 |
| 57 IOSChromeUnitTestSuite::IOSChromeUnitTestSuite(int argc, char** argv) | 59 IOSChromeUnitTestSuite::IOSChromeUnitTestSuite(int argc, char** argv) |
| 58 : web::WebTestSuite(argc, argv) {} | 60 : web::WebTestSuite(argc, argv), |
| 61 action_task_runner_(new base::TestSimpleTaskRunner) {} |
| 59 | 62 |
| 60 IOSChromeUnitTestSuite::~IOSChromeUnitTestSuite() {} | 63 IOSChromeUnitTestSuite::~IOSChromeUnitTestSuite() {} |
| 61 | 64 |
| 62 void IOSChromeUnitTestSuite::Initialize() { | 65 void IOSChromeUnitTestSuite::Initialize() { |
| 63 // Add an additional listener to do the extra initialization for unit tests. | 66 // Add an additional listener to do the extra initialization for unit tests. |
| 64 // It will be started before the base class listeners and ended after the | 67 // It will be started before the base class listeners and ended after the |
| 65 // base class listeners. | 68 // base class listeners. |
| 66 testing::TestEventListeners& listeners = | 69 testing::TestEventListeners& listeners = |
| 67 testing::UnitTest::GetInstance()->listeners(); | 70 testing::UnitTest::GetInstance()->listeners(); |
| 68 listeners.Append(new IOSChromeUnitTestSuiteInitializer); | 71 listeners.Append(new IOSChromeUnitTestSuiteInitializer); |
| 69 | 72 |
| 70 // Call the superclass Initialize() method after adding the listener. | 73 // Call the superclass Initialize() method after adding the listener. |
| 71 web::WebTestSuite::Initialize(); | 74 web::WebTestSuite::Initialize(); |
| 72 | 75 |
| 73 // Ensure that all BrowserStateKeyedServiceFactories are built before any | 76 // Ensure that all BrowserStateKeyedServiceFactories are built before any |
| 74 // test is run so that the dependencies are correctly resolved. | 77 // test is run so that the dependencies are correctly resolved. |
| 75 EnsureBrowserStateKeyedServiceFactoriesBuilt(); | 78 EnsureBrowserStateKeyedServiceFactoriesBuilt(); |
| 76 | 79 |
| 80 // Register a SingleThreadTaskRunner for base::RecordAction as overridding |
| 81 // it in individual tests is unsafe (as there is no way to unregister). |
| 82 base::SetRecordActionTaskRunner(action_task_runner_); |
| 83 |
| 77 ios::RegisterPathProvider(); | 84 ios::RegisterPathProvider(); |
| 78 ui::RegisterPathProvider(); | 85 ui::RegisterPathProvider(); |
| 79 url::AddStandardScheme(kChromeUIScheme, url::SCHEME_WITHOUT_PORT); | 86 url::AddStandardScheme(kChromeUIScheme, url::SCHEME_WITHOUT_PORT); |
| 80 ContentSettingsPattern::SetNonWildcardDomainNonPortScheme( | 87 ContentSettingsPattern::SetNonWildcardDomainNonPortScheme( |
| 81 kDummyExtensionScheme); | 88 kDummyExtensionScheme); |
| 82 } | 89 } |
| OLD | NEW |