From 64778080fbb9b8f7dac88b1daee75d40244624c0 Mon Sep 17 00:00:00 2001 From: Sylvain Defresne Date: Mon, 9 Oct 2017 14:59:27 +0000 Subject: [PATCH] Ensure that autorelease pool is drained between each tests. The TEST macro uses a test fixture of type testing::Test that does not drain the autorelease pool at the end of the test. Instead use TEST_F with PlatformTest as the fixture as it drain the autorelease pool during its TearDown method. Change all test fixture inheriting from testing::Test to instead inherit from PlatformTest (also for those using parametrisation). Changes initially automated with a one-shot script and formatting fixed by git cl format. Additional changes were necessary to fix the compilation. Bug: none Change-Id: I35651b5aebb7148efee6eaa59d6582c0c6c3b771 Reviewed-on: https://chromium-review.googlesource.com/704821 Commit-Queue: Sylvain Defresne Reviewed-by: Rohit Rao (ping after 24h) Cr-Commit-Position: refs/heads/master@{#507375} --- .../app_state_unittest.mm | 4 +- .../background_activity_unittest.mm | 6 ++- .../metrics_mediator_unittest.mm | 12 ++++-- .../user_activity_handler_unittest.mm | 28 +++++++------ ...deferred_initialization_runner_unittest.mm | 14 ++++--- .../app/main_application_delegate_unittest.mm | 4 +- .../spotlight/spotlight_manager_unittest.mm | 3 +- .../app_startup_parameters_unittest.mm | 5 ++- .../browser/callback_counter_unittest.mm | 4 +- .../browser/chrome_url_util_unittest.mm | 11 +++-- ...t_suggestions_category_wrapper_unittest.mm | 11 +++-- .../drop_and_navigate_interaction_unittest.mm | 5 ++- .../favicon/large_icon_cache_unittest.cc | 3 +- .../geolocation/CLLocation+XGeoHeaderTest.mm | 5 ++- .../browser/install_time_util_unittest.mm | 5 ++- .../language_model_factory_unittest.cc | 7 +++- ...url_language_histogram_factory_unittest.cc | 3 +- ...hrome_metrics_service_accessor_unittest.cc | 3 +- ...ome_stability_metrics_provider_unittest.cc | 3 +- ...sion_shutdown_metrics_provider_unittest.mm | 4 +- .../metrics/previous_session_info_unittest.mm | 22 ++++++---- .../browser/net/cookie_util_unittest.mm | 5 ++- .../browser/notification_promo_unittest.cc | 3 +- .../credential_manager_util_unittest.cc | 16 ++++---- .../passwords/password_controller_unittest.mm | 5 ++- .../ios_payment_instrument_finder_unittest.mm | 3 +- ...os_payment_instrument_launcher_unittest.mm | 3 +- .../payments/payment_request_unittest.mm | 3 +- .../offline_url_utils_unittest.cc | 19 +++++---- .../reading_list/url_downloader_unittest.mm | 3 +- .../browser/snapshots/lru_cache_unittest.mm | 5 ++- .../snapshots/snapshots_util_unittest.mm | 5 ++- ...e_profile_sync_service_factory_unittest.cc | 3 +- .../translate_service_ios_unittest.cc | 5 ++- .../activity_type_util_unittest.mm | 9 ++-- .../share_to_data_builder_unittest.mm | 7 +++- .../action_sheet_coordinator_unittest.mm | 4 +- .../input_alert_coordinator_unittest.mm | 6 ++- .../account_control_item_unittest.mm | 7 +++- .../authentication_ui_util_unittest.mm | 9 ++-- .../signin_promo_item_unittest.mm | 5 ++- .../signin_promo_view_unittest.mm | 7 +++- .../cells/autofill_edit_item_unittest.mm | 5 ++- .../ui/autofill/cells/cvc_item_unittest.mm | 5 ++- .../ui/autofill/cells/status_item_unittest.mm | 5 ++- .../cells/storage_switch_item_unittest.mm | 7 +++- .../bookmarks/bookmark_path_cache_unittest.mm | 5 ++- .../bookmark_position_cache_unittest.mm | 5 ++- .../bookmark_parent_folder_item_unittest.mm | 5 ++- .../bookmark_text_field_item_unittest.mm | 7 +++- .../MDCCollectionViewCell+Chrome_unittest.mm | 7 +++- .../cells/activity_indicator_cell_unittest.mm | 5 ++- .../collection_view_account_item_unittest.mm | 5 ++- .../collection_view_detail_item_unittest.mm | 9 +++- .../collection_view_footer_item_unittest.mm | 5 ++- .../cells/collection_view_item_unittest.mm | 7 +++- .../collection_view_switch_item_unittest.mm | 9 ++-- .../collection_view_text_item_unittest.mm | 11 +++-- .../collection_view_model_unittest.mm | 41 ++++++++++--------- .../commands/command_dispatcher_unittest.mm | 29 +++++++------ ...ontent_suggestions_footer_item_unittest.mm | 7 +++- ...ontent_suggestions_header_item_unittest.mm | 7 +++- .../content_suggestions_item_unittest.mm | 13 +++--- ...nt_suggestions_learn_more_item_unittest.mm | 7 +++- ..._suggestions_most_visited_item_unittest.mm | 7 +++- ...ent_suggestions_whats_new_item_unittest.mm | 7 +++- ...suggestions_collection_updater_unittest.mm | 10 +++-- .../content_suggestion_identifier_unittest.mm | 9 ++-- ...to_search_permissions_mediator_unittest.mm | 10 +++-- .../nsurl_protection_space_util_unittest.mm | 16 ++++---- .../activity_overlay_coordinator_unittest.mm | 5 ++- .../elements/selector_coordinator_unittest.mm | 7 +++- ...elector_picker_view_controller_unittest.mm | 9 ++-- .../ui/first_run/first_run_util_unittest.mm | 5 ++- .../history_entries_status_item_unittest.mm | 9 ++-- .../ui/history/history_entry_item_unittest.mm | 7 +++- .../browser/ui/icons/chrome_icon_unittest.mm | 11 +++-- .../ui/key_commands_provider_unittest.mm | 10 +++-- .../ui/keyboard/UIKeyCommand+ChromeTest.mm | 5 ++- .../ui/main/main_coordinator_unittest.mm | 5 ++- .../ui/native_content_controller_unittest.mm | 11 +++-- .../page_not_available_controller_unittest.mm | 10 +++-- .../accepted_payment_methods_item_unittest.mm | 5 ++- .../cells/autofill_profile_item_unittest.mm | 5 ++- .../payments/cells/page_info_item_unittest.mm | 5 ++- .../cells/payment_method_item_unittest.mm | 5 ++- .../payments_selector_edit_item_unittests.mm | 5 ++- .../cells/payments_text_item_unittest.mm | 5 ++- .../ui/payments/cells/price_item_unittest.mm | 7 +++- .../country_selection_coordinator_unittest.mm | 2 +- ...ment_request_error_coordinator_unittest.mm | 2 +- ...ist_collection_view_controller_unittest.mm | 4 +- .../reading_list/text_badge_view_unittest.mm | 9 ++-- .../safe_mode_coordinator_unittest.mm | 5 ++- .../cells/account_signin_item_unittest.mm | 5 ++- .../cells/autofill_data_item_unittest.mm | 5 ++- .../cells/byo_textfield_item_unittest.mm | 5 ++- .../cells/card_multiline_item_unittest.mm | 7 +++- .../cells/copied_to_chrome_item_unittest.mm | 5 ++- .../cells/encryption_item_unittest.mm | 5 ++- ...ort_data_multiline_detail_cell_unittest.mm | 7 +++- .../cells/passphrase_error_item_unittest.mm | 5 ++- .../cells/password_details_item_unittest.mm | 5 ++- .../cells/sync_switch_item_unittest.mm | 9 ++-- .../cells/text_and_error_item_unittest.mm | 5 ++- .../settings/cells/version_item_unittest.mm | 5 ++- .../snackbar/snackbar_coordinator_unittest.mm | 5 ++- .../card_stack_layout_manager_unittest.mm | 3 +- ios/chrome/browser/ui/ui_util_unittest.mm | 15 ++++--- .../browser/ui/uikit_ui_util_unittest.mm | 19 +++++---- .../ui/util/constraints_ui_util_unittest.mm | 4 +- .../ui/util/core_text_util_unittest.mm | 8 ++-- .../browser/ui/util/named_guide_unittest.mm | 9 ++-- ...e_update_query_params_delegate_unittest.cc | 5 ++- .../voice/text_to_speech_parser_unittest.mm | 7 +++- .../web/external_app_launcher_unittest.mm | 9 ++-- .../web/mailto_handler_gmail_unittest.mm | 5 ++- .../web/mailto_handler_inbox_unittest.mm | 5 ++- .../mailto_handler_system_mail_unittest.mm | 7 +++- .../browser/web/mailto_handler_unittest.mm | 15 ++++--- ..._activity_indicator_tab_helper_unittest.mm | 9 ++-- .../web_resource_util_unittest.cc | 3 +- .../common/ns_regular_expression_unittest.mm | 10 +++-- ios/chrome/common/string_util_unittest.mm | 10 +++-- ios/chrome/common/x_callback_url_unittest.cc | 9 ++-- .../base/scoped_block_swizzler_unittest.mm | 10 +++-- ios/chrome/test/google_toolbox_unittest.mm | 5 ++- .../app/steps/phased_step_runner_unittest.mm | 18 ++++---- .../context_menu_dialog_mediator_unittest.mm | 11 +++-- .../dialog_button_configuration_unittest.mm | 7 +++- ...ialog_configuration_identifier_unittest.mm | 7 +++- ...ialog_text_field_configuration_unittest.mm | 7 +++- .../dialog_view_controller_unittest.mm | 5 ++- ...ilable_feature_dialog_mediator_unittest.mm | 5 ++- .../ui/root/root_coordinator_unittest.mm | 5 ++- .../swap_from_above_animator_unittest.mm | 5 ++- ...containment_transition_context_unittest.mm | 17 ++++---- ios/net/cookies/cookie_cache_unittest.cc | 19 +++++---- .../cookie_creation_time_manager_unittest.mm | 3 +- .../cookie_store_ios_persistent_unittest.mm | 3 +- ios/net/cookies/cookie_store_ios_unittest.mm | 6 +-- .../cookies/system_cookie_util_unittest.mm | 9 ++-- .../http_response_headers_util_unittest.mm | 5 ++- ios/net/nsurlrequest_util_unittest.mm | 5 ++- ios/net/protocol_handler_util_unittest.mm | 3 +- ios/net/url_scheme_util_unittest.mm | 5 ++- ios/web/browser_state_unittest.cc | 9 ++-- ios/web/history_state_util_unittest.mm | 3 +- ios/web/net/cert_policy_unittest.cc | 5 ++- ios/web/net/request_group_util_unittest.mm | 7 +++- ...http_protocol_handler_delegate_unittest.mm | 3 +- ios/web/payments/payment_request_unittest.cc | 19 +++++---- ...rtificate_policy_cache_storage_unittest.mm | 4 +- ios/web/public/origin_util_unittest.mm | 7 +++- ios/web/public/referrer_util_unittest.cc | 25 ++++++----- ios/web/public/user_agent_unittest.mm | 5 ++- .../web_state/page_viewport_state_unittest.mm | 17 +++++--- ...ervice_manager_connection_impl_unittest.cc | 5 ++- ios/web/url_scheme_util_unittest.mm | 7 +++- ios/web/url_util_unittest.cc | 5 ++- .../web_state/page_display_state_unittest.mm | 11 +++-- ...e_policy_cache_storage_builder_unittest.mm | 9 ++-- ...crw_web_view_scroll_view_proxy_unittest.mm | 3 +- .../ui/web_view_js_utils_unittest.mm | 23 ++++++----- .../internal/cwv_html_element_unittest.mm | 5 ++- .../cwv_preview_element_info_unittest.mm | 5 ++- 166 files changed, 857 insertions(+), 417 deletions(-) diff --git a/ios/chrome/app/application_delegate/app_state_unittest.mm b/ios/chrome/app/application_delegate/app_state_unittest.mm index 29b62be2888168..5d81095859901a 100644 --- a/ios/chrome/app/application_delegate/app_state_unittest.mm +++ b/ios/chrome/app/application_delegate/app_state_unittest.mm @@ -449,8 +449,10 @@ void trackerCreationFailed() { EXPECT_OCMOCK_VERIFY(browserLauncherMock); } +using AppStateNoFixtureTest = PlatformTest; + // Test that -willResignActive set cold start to NO and launch record. -TEST(AppStateNoFixtureTest, willResignActive) { +TEST_F(AppStateNoFixtureTest, willResignActive) { // Setup. id tabModel = [OCMockObject mockForClass:[TabModel class]]; [[tabModel expect] recordSessionMetrics]; diff --git a/ios/chrome/app/application_delegate/background_activity_unittest.mm b/ios/chrome/app/application_delegate/background_activity_unittest.mm index 2c6a5d315473b5..89e3be4daaa87d 100644 --- a/ios/chrome/app/application_delegate/background_activity_unittest.mm +++ b/ios/chrome/app/application_delegate/background_activity_unittest.mm @@ -18,9 +18,11 @@ #error "This file requires ARC support." #endif +using BackgroundActivityTest = PlatformTest; + // Verifies that -application:performFetchWithCompletionHandler: calls the // browser launcher in background state and uploads the report. -TEST(BackgroundActivityTest, performFetchWithCompletionHandler) { +TEST_F(BackgroundActivityTest, performFetchWithCompletionHandler) { // Setup. [[PreviousSessionInfo sharedInstance] setIsFirstSessionAfterUpgrade:NO]; @@ -58,7 +60,7 @@ ScopedBlockSwizzler crash_report_completion_handler_swizzler( // Verifies that -handleEventsForBackgroundURLSession:completionHandler: calls // the browser launcher in background state. -TEST(BackgroundActivityTest, handleEventsForBackgroundURLSession) { +TEST_F(BackgroundActivityTest, handleEventsForBackgroundURLSession) { // Setup. // BrowserLauncher mock. id browser_launcher = diff --git a/ios/chrome/app/application_delegate/metrics_mediator_unittest.mm b/ios/chrome/app/application_delegate/metrics_mediator_unittest.mm index a010802e1fdacc..b42357282a977c 100644 --- a/ios/chrome/app/application_delegate/metrics_mediator_unittest.mm +++ b/ios/chrome/app/application_delegate/metrics_mediator_unittest.mm @@ -92,9 +92,11 @@ int getExpectedValue(int number) { return 1; } +using MetricsMediatorTest = PlatformTest; + // Verifies that connectionTypeChanged correctly enables or disables the // uploading in the breakpad and in the metrics service. -TEST(MetricsMediatorTest, connectionTypeChanged) { +TEST_F(MetricsMediatorTest, connectionTypeChanged) { [[PreviousSessionInfo sharedInstance] setIsFirstSessionAfterUpgrade:NO]; MetricsMediatorMock* mock_metrics_helper = [[MetricsMediatorMock alloc] init]; @@ -216,8 +218,10 @@ void initiateMetricsMediator(BOOL coldStart, int tabCount) { verifySwizzleHasBeenCalled(); } +using MetricsMediatorNoFixtureTest = PlatformTest; + // Tests that +logDateInUserDefaults logs the date in UserDefaults. -TEST(MetricsMediatorNoFixtureTest, logDateInUserDefaultsTest) { +TEST_F(MetricsMediatorNoFixtureTest, logDateInUserDefaultsTest) { // Setup. [[NSUserDefaults standardUserDefaults] removeObjectForKey:metrics_mediator::kAppEnteredBackgroundDateKey]; @@ -238,7 +242,9 @@ void initiateMetricsMediator(BOOL coldStart, int tabCount) { #pragma mark - processCrashReportsPresentAtStartup tests. -class MetricsMediatorShutdownTypeTest : public testing::TestWithParam {}; +class MetricsMediatorShutdownTypeTest + : public PlatformTest, + public testing::WithParamInterface {}; // Verifies that the Breakpad controller gets called appropriately when // processCrashReportsPresentAtStartup is invoked. diff --git a/ios/chrome/app/application_delegate/user_activity_handler_unittest.mm b/ios/chrome/app/application_delegate/user_activity_handler_unittest.mm index a9c8cc0e91f8ac..e693ce331e8c67 100644 --- a/ios/chrome/app/application_delegate/user_activity_handler_unittest.mm +++ b/ios/chrome/app/application_delegate/user_activity_handler_unittest.mm @@ -166,10 +166,12 @@ conditionBlock getCompletionHandler() { #pragma mark - Tests. +using UserActivityHandlerNoFixtureTest = PlatformTest; + // Tests that Chrome notifies the user if we are passing a correct // userActivityType. -TEST(UserActivityHandlerNoFixtureTest, - willContinueUserActivityCorrectActivity) { +TEST_F(UserActivityHandlerNoFixtureTest, + willContinueUserActivityCorrectActivity) { EXPECT_TRUE([UserActivityHandler willContinueUserActivityWithType:handoff::kChromeHandoffActivityType]); @@ -181,8 +183,8 @@ conditionBlock getCompletionHandler() { // Tests that Chrome does not notifies the user if we are passing an incorrect // userActivityType. -TEST(UserActivityHandlerNoFixtureTest, - willContinueUserActivityIncorrectActivity) { +TEST_F(UserActivityHandlerNoFixtureTest, + willContinueUserActivityIncorrectActivity) { EXPECT_FALSE([UserActivityHandler willContinueUserActivityWithType:[handoff::kChromeHandoffActivityType stringByAppendingString:@"test"]]); @@ -195,9 +197,11 @@ conditionBlock getCompletionHandler() { EXPECT_FALSE([UserActivityHandler willContinueUserActivityWithType:nil]); } +using UserActivityHandlerNoFixtureTest = PlatformTest; + // Tests that Chrome does not continue the activity is the activity type is // random. -TEST(UserActivityHandlerNoFixtureTest, continueUserActivityFromGarbage) { +TEST_F(UserActivityHandlerNoFixtureTest, continueUserActivityFromGarbage) { // Setup. NSString* handoffWithSuffix = [handoff::kChromeHandoffActivityType stringByAppendingString:@"test"]; @@ -230,7 +234,7 @@ conditionBlock getCompletionHandler() { // Tests that Chrome does not continue the activity if the webpage url is not // set. -TEST(UserActivityHandlerNoFixtureTest, continueUserActivityNoWebpage) { +TEST_F(UserActivityHandlerNoFixtureTest, continueUserActivityNoWebpage) { // Setup. NSUserActivity* userActivity = [[NSUserActivity alloc] initWithActivityType:handoff::kChromeHandoffActivityType]; @@ -253,8 +257,8 @@ conditionBlock getCompletionHandler() { // Tests that Chrome does not continue the activity if the activity is a // Spotlight action of an unknown type. -TEST(UserActivityHandlerNoFixtureTest, - continueUserActivitySpotlightActionFromGarbage) { +TEST_F(UserActivityHandlerNoFixtureTest, + continueUserActivitySpotlightActionFromGarbage) { // Only test Spotlight if it is enabled and available on the device. if (!spotlight::IsSpotlightAvailable()) { return; @@ -292,7 +296,7 @@ conditionBlock getCompletionHandler() { // Tests that Chrome continues the activity if the application is in background // by saving the url to startupParameters. -TEST(UserActivityHandlerNoFixtureTest, continueUserActivityBackground) { +TEST_F(UserActivityHandlerNoFixtureTest, continueUserActivityBackground) { // Setup. NSUserActivity* userActivity = [[NSUserActivity alloc] initWithActivityType:handoff::kChromeHandoffActivityType]; @@ -327,7 +331,7 @@ conditionBlock getCompletionHandler() { // Tests that Chrome continues the activity if the application is in foreground // by opening a new tab. -TEST(UserActivityHandlerNoFixtureTest, continueUserActivityForeground) { +TEST_F(UserActivityHandlerNoFixtureTest, continueUserActivityForeground) { // Setup. NSUserActivity* userActivity = [[NSUserActivity alloc] initWithActivityType:handoff::kChromeHandoffActivityType]; @@ -453,7 +457,7 @@ conditionBlock getCompletionHandler() { } // Tests that handleStartupParameters with a non-U2F url opens a new tab. -TEST(UserActivityHandlerNoFixtureTest, handleStartupParamsNonU2F) { +TEST_F(UserActivityHandlerNoFixtureTest, handleStartupParamsNonU2F) { // Setup. GURL gurl("http://www.google.com"); @@ -487,7 +491,7 @@ conditionBlock getCompletionHandler() { } // Tests that handleStartupParameters with a U2F url opens in the correct tab. -TEST(UserActivityHandlerNoFixtureTest, handleStartupParamsU2F) { +TEST_F(UserActivityHandlerNoFixtureTest, handleStartupParamsU2F) { // Setup. GURL gurl("chromium://u2f-callback?isU2F=1&tabID=B05B1860"); NSString* tabID = [U2FController tabIDFromResponseURL:gurl]; diff --git a/ios/chrome/app/deferred_initialization_runner_unittest.mm b/ios/chrome/app/deferred_initialization_runner_unittest.mm index 6ed95f99e6a39a..4ef54834869b2a 100644 --- a/ios/chrome/app/deferred_initialization_runner_unittest.mm +++ b/ios/chrome/app/deferred_initialization_runner_unittest.mm @@ -12,7 +12,9 @@ #error "This file requires ARC support." #endif -TEST(DeferredInitializationRunnerTest, TestSharedInstance) { +using DeferredInitializationRunnerTest = PlatformTest; + +TEST_F(DeferredInitializationRunnerTest, TestSharedInstance) { EXPECT_TRUE([DeferredInitializationRunner sharedInstance]); // Cancelling a non-existing block does nothing. [[DeferredInitializationRunner sharedInstance] @@ -20,7 +22,7 @@ } // Tests that all blocks added on the queue are executed after a delay. -TEST(DeferredInitializationRunnerTest, TestRunBlockSequentially) { +TEST_F(DeferredInitializationRunnerTest, TestRunBlockSequentially) { // Setup. __block bool firstFlag = NO; __block bool secondFlag = NO; @@ -58,7 +60,7 @@ // Tests that runBlockIfNecessary does not execute the block if it has already // been executed and runs synchronously the one not executed. -TEST(DeferredInitializationRunnerTest, TestRunBlock) { +TEST_F(DeferredInitializationRunnerTest, TestRunBlock) { // Setup. __block bool quickFlag = NO; __block bool slowFlag = NO; @@ -98,7 +100,7 @@ // Tests that a block is not executed when cancelled and it is removed from the // remaining blocks list. -TEST(DeferredInitializationRunnerTest, TestCancelBlock) { +TEST_F(DeferredInitializationRunnerTest, TestCancelBlock) { // Setup. __block BOOL blockFinished = NO; DeferredInitializationRunner* runner = @@ -121,7 +123,7 @@ } // Tests that a cancelled block will do nothing when run by name. -TEST(DeferredInitializationRunnerTest, TestCancelledBlockDoNothing) { +TEST_F(DeferredInitializationRunnerTest, TestCancelledBlockDoNothing) { // Setup. __block BOOL blockFinished = NO; DeferredInitializationRunner* runner = @@ -145,7 +147,7 @@ // Tests that adding a block with the same name as an existing block will // override the existing one. -TEST(DeferredInitializationRunnerTest, TestSecondBlockInvalidatesFirst) { +TEST_F(DeferredInitializationRunnerTest, TestSecondBlockInvalidatesFirst) { // Setup. __block int blockRunCount = 0; ProceduralBlock runBlock = ^() { diff --git a/ios/chrome/app/main_application_delegate_unittest.mm b/ios/chrome/app/main_application_delegate_unittest.mm index 621237d2e53292..53432b69dacfe0 100644 --- a/ios/chrome/app/main_application_delegate_unittest.mm +++ b/ios/chrome/app/main_application_delegate_unittest.mm @@ -16,10 +16,12 @@ #error "This file requires ARC support." #endif +using MainApplicationDelegateTest = PlatformTest; + // Tests that the application does not crash if |applicationDidEnterBackground| // is called when the application is launched in background. // http://crbug.com/437307 -TEST(MainApplicationDelegateTest, CrashIfNotInitialized) { +TEST_F(MainApplicationDelegateTest, CrashIfNotInitialized) { // Save both ChromeBrowserProvider as MainController register new instance. ios::ChromeBrowserProvider* stashed_chrome_browser_provider = ios::GetChromeBrowserProvider(); diff --git a/ios/chrome/app/spotlight/spotlight_manager_unittest.mm b/ios/chrome/app/spotlight/spotlight_manager_unittest.mm index 4a08c1ac40575b..89bc8ee45919a0 100644 --- a/ios/chrome/app/spotlight/spotlight_manager_unittest.mm +++ b/ios/chrome/app/spotlight/spotlight_manager_unittest.mm @@ -27,6 +27,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -60,7 +61,7 @@ return result; } -class SpotlightManagerTest : public testing::Test { +class SpotlightManagerTest : public PlatformTest { protected: SpotlightManagerTest() { model_ = bookmarks::TestBookmarkClient::CreateModel(); diff --git a/ios/chrome/browser/app_startup_parameters_unittest.mm b/ios/chrome/browser/app_startup_parameters_unittest.mm index de226ab6838f07..6c445a69743953 100644 --- a/ios/chrome/browser/app_startup_parameters_unittest.mm +++ b/ios/chrome/browser/app_startup_parameters_unittest.mm @@ -5,6 +5,7 @@ #include "ios/chrome/browser/app_startup_parameters.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -19,7 +20,9 @@ bool expected_complete_payment_request; }; -TEST(AppStartupParameters, QueryParametersPaymentRequest) { +using AppStartupParametersTest = PlatformTest; + +TEST_F(AppStartupParametersTest, QueryParametersPaymentRequest) { const UniversalLinkDecodeTestCase test_cases[] = { { GURL("https://goo.gl/ioschrome/"), {}, false, diff --git a/ios/chrome/browser/callback_counter_unittest.mm b/ios/chrome/browser/callback_counter_unittest.mm index 848ab2afb7bfb8..a58911fa88bc74 100644 --- a/ios/chrome/browser/callback_counter_unittest.mm +++ b/ios/chrome/browser/callback_counter_unittest.mm @@ -14,8 +14,10 @@ #error "This file requires ARC support." #endif +using CallbackCounterTest = PlatformTest; + // Tests that CallbackCounter works with 2 callbacks. -TEST(CallbackCounterTest, Basic) { +TEST_F(CallbackCounterTest, Basic) { __block BOOL block_was_called = NO; scoped_refptr callback_counter = new CallbackCounter(base::BindBlockArc(^{ diff --git a/ios/chrome/browser/chrome_url_util_unittest.mm b/ios/chrome/browser/chrome_url_util_unittest.mm index 783cac7bde97ac..a898f466b53ee7 100644 --- a/ios/chrome/browser/chrome_url_util_unittest.mm +++ b/ios/chrome/browser/chrome_url_util_unittest.mm @@ -9,6 +9,7 @@ #include "ios/chrome/browser/chrome_url_constants.h" #import "net/base/mac/url_conversions.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -17,7 +18,9 @@ namespace { -TEST(ChromeURLUtilTest, TestIsExternalFileReference) { +using ChromeURLUtilTest = PlatformTest; + +TEST_F(ChromeURLUtilTest, TestIsExternalFileReference) { GURL external_url("chrome://external-file/foo/bar"); GURL not_external_url("chrome://foo/bar"); GURL still_not_external_url("http://external-file/foo/bar"); @@ -35,7 +38,7 @@ }; // Tests UrlHasChromeScheme with NSURL* parameter. -TEST(ChromeURLUtilTest, NSURLHasChromeScheme) { +TEST_F(ChromeURLUtilTest, NSURLHasChromeScheme) { for (unsigned int i = 0; i < arraysize(kSchemeTestData); ++i) { const char* url = kSchemeTestData[i]; NSURL* nsurl = [NSURL URLWithString:base::SysUTF8ToNSString(url)]; @@ -46,7 +49,7 @@ } // Tests UrlHasChromeScheme with const GURL& paramter. -TEST(ChromeURLUtilTest, GURLHasChromeScheme) { +TEST_F(ChromeURLUtilTest, GURLHasChromeScheme) { for (unsigned int i = 0; i < arraysize(kSchemeTestData); ++i) { GURL gurl(kSchemeTestData[i]); bool result = UrlHasChromeScheme(gurl); @@ -55,7 +58,7 @@ } } -TEST(ChromeURLUtilTest, GetBundleURLScheme) { +TEST_F(ChromeURLUtilTest, GetBundleURLScheme) { // Verifies that there is some default values. ChromeAppConstants* constants = [ChromeAppConstants sharedInstance]; NSString* originalScheme = [constants getBundleURLScheme]; diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper_unittest.mm b/ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper_unittest.mm index 0e18aacf8bdc62..6ae8a723c96ba2 100644 --- a/ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper_unittest.mm +++ b/ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper_unittest.mm @@ -6,6 +6,7 @@ #include "components/ntp_snippets/category.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -21,9 +22,11 @@ @implementation ContentSuggestionsCategoryWrapperSubclassTest #pragma mark - Tests. +using ContentSuggestionsCategoryWrapperTest = PlatformTest; + // Tests that the category returned by the wrapper is the one given in the // initializer. -TEST(ContentSuggestionsCategoryWrapperTest, GetCategory) { +TEST_F(ContentSuggestionsCategoryWrapperTest, GetCategory) { // Setup. ntp_snippets::Category category = ntp_snippets::Category::FromIDValue(2); ContentSuggestionsCategoryWrapper* wrapper = @@ -34,7 +37,7 @@ @implementation ContentSuggestionsCategoryWrapperSubclassTest } // Tests that two wrappers created with equal categories are equal. -TEST(ContentSuggestionsCategoryWrapperTest, AreWrappersEqual) { +TEST_F(ContentSuggestionsCategoryWrapperTest, AreWrappersEqual) { // Setup. ntp_snippets::Category category = ntp_snippets::Category::FromIDValue(2); ContentSuggestionsCategoryWrapper* wrapper = @@ -50,7 +53,7 @@ @implementation ContentSuggestionsCategoryWrapperSubclassTest } // Tests that two wrappers created with different categories are not equal. -TEST(ContentSuggestionsCategoryWrapperTest, AreWrappersDifferent) { +TEST_F(ContentSuggestionsCategoryWrapperTest, AreWrappersDifferent) { // Setup. ntp_snippets::Category category = ntp_snippets::Category::FromIDValue(2); ContentSuggestionsCategoryWrapper* wrapper = @@ -65,7 +68,7 @@ @implementation ContentSuggestionsCategoryWrapperSubclassTest } // Tests the equality between a wrapper an different type of objects. -TEST(ContentSuggestionsCategoryWrapperTest, DifferentObject) { +TEST_F(ContentSuggestionsCategoryWrapperTest, DifferentObject) { // Setup. ntp_snippets::Category category = ntp_snippets::Category::FromIDValue(2); ContentSuggestionsCategoryWrapper* wrapper = diff --git a/ios/chrome/browser/drag_and_drop/drop_and_navigate_interaction_unittest.mm b/ios/chrome/browser/drag_and_drop/drop_and_navigate_interaction_unittest.mm index 2344cd7f49d8df..bb70c9171eb127 100644 --- a/ios/chrome/browser/drag_and_drop/drop_and_navigate_interaction_unittest.mm +++ b/ios/chrome/browser/drag_and_drop/drop_and_navigate_interaction_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "base/logging.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,7 +14,9 @@ namespace { -TEST(DropAndNavigateTest, Instantiation) { +using DropAndNavigateTest = PlatformTest; + +TEST_F(DropAndNavigateTest, Instantiation) { #if defined(__IPHONE_11_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0) if (@available(iOS 11, *)) { DropAndNavigateInteraction* interaction = diff --git a/ios/chrome/browser/favicon/large_icon_cache_unittest.cc b/ios/chrome/browser/favicon/large_icon_cache_unittest.cc index c9823f4ee803d5..e3986846540ce1 100644 --- a/ios/chrome/browser/favicon/large_icon_cache_unittest.cc +++ b/ios/chrome/browser/favicon/large_icon_cache_unittest.cc @@ -9,6 +9,7 @@ #include "components/favicon_base/favicon_types.h" #include "skia/ext/skia_utils_ios.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #include "ui/gfx/codec/png_codec.h" namespace { @@ -38,7 +39,7 @@ favicon_base::FaviconRawBitmapResult CreateTestBitmap(int w, return result; } -class LargeIconCacheTest : public testing::Test { +class LargeIconCacheTest : public PlatformTest { public: LargeIconCacheTest() { expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle()); diff --git a/ios/chrome/browser/geolocation/CLLocation+XGeoHeaderTest.mm b/ios/chrome/browser/geolocation/CLLocation+XGeoHeaderTest.mm index 76104e8eb2587f..ecda6c5f5d3d9b 100644 --- a/ios/chrome/browser/geolocation/CLLocation+XGeoHeaderTest.mm +++ b/ios/chrome/browser/geolocation/CLLocation+XGeoHeaderTest.mm @@ -6,6 +6,7 @@ #import "ios/chrome/browser/geolocation/CLLocation+XGeoHeader.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -18,7 +19,9 @@ "zdGFtcDogMTM4OTAwMDAwMDAwMDAwMApyYWRpdXM6IDEwMDAwCmxhdGxuZyA8CiAgbGF0aXR1" "ZGVfZTc6IDM3Nzk2MzIyMAogIGxvbmdpdHVkZV9lNzogLTEyMjQwMDI5MTAKPg=="; -TEST(CLLocationXGeoHeaderTest, TestXGeoString) { +using CLLocationXGeoHeaderTest = PlatformTest; + +TEST_F(CLLocationXGeoHeaderTest, TestXGeoString) { CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(37.796322, -122.400291); // Picked a fixed timestamp. This one is 2014-01-06 09:20:00 +0000. diff --git a/ios/chrome/browser/install_time_util_unittest.mm b/ios/chrome/browser/install_time_util_unittest.mm index e539e578520311..945d154bb81859 100644 --- a/ios/chrome/browser/install_time_util_unittest.mm +++ b/ios/chrome/browser/install_time_util_unittest.mm @@ -5,12 +5,15 @@ #include "ios/chrome/browser/install_time_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif -TEST(InstallTimeUtilTest, ComputeInstallationTime) { +using InstallTimeUtilTest = PlatformTest; + +TEST_F(InstallTimeUtilTest, ComputeInstallationTime) { const base::Time null_time = base::Time(); const base::Time now = base::Time::Now(); const base::Time one_month_ago = now - base::TimeDelta::FromDays(30); diff --git a/ios/chrome/browser/language/language_model_factory_unittest.cc b/ios/chrome/browser/language/language_model_factory_unittest.cc index cd55d3e780802d..b36ce174770d6d 100644 --- a/ios/chrome/browser/language/language_model_factory_unittest.cc +++ b/ios/chrome/browser/language/language_model_factory_unittest.cc @@ -9,15 +9,18 @@ #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" #include "ios/web/public/test/test_web_thread_bundle.h" #include "testing/gmock/include/gmock/gmock.h" +#include "testing/platform_test.h" using base::test::ScopedFeatureList; using testing::Eq; using testing::IsNull; using testing::Not; +using LanguageModelFactoryTest = PlatformTest; + // Check that the language model is not returned unless the experiment is // enabled. -TEST(LanguageModelFactoryTest, Disabled) { +TEST_F(LanguageModelFactoryTest, Disabled) { ScopedFeatureList disable_feature; disable_feature.InitAndDisableFeature(language::kUseBaselineLanguageModel); web::TestWebThreadBundle thread_bundle; @@ -35,7 +38,7 @@ TEST(LanguageModelFactoryTest, Disabled) { } // Check that Incognito language modeling is inherited from the user's profile. -TEST(LanguageModelFactoryTest, SharedWithIncognito) { +TEST_F(LanguageModelFactoryTest, SharedWithIncognito) { ScopedFeatureList enable_feature; enable_feature.InitAndEnableFeature(language::kUseBaselineLanguageModel); web::TestWebThreadBundle thread_bundle; diff --git a/ios/chrome/browser/language/url_language_histogram_factory_unittest.cc b/ios/chrome/browser/language/url_language_histogram_factory_unittest.cc index de91204ac66e6f..3e18f801338dd6 100644 --- a/ios/chrome/browser/language/url_language_histogram_factory_unittest.cc +++ b/ios/chrome/browser/language/url_language_histogram_factory_unittest.cc @@ -8,11 +8,12 @@ #include "ios/web/public/test/test_web_thread_bundle.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" using testing::IsNull; using testing::Not; -class UrlLanguageHistogramFactoryTest : public testing::Test { +class UrlLanguageHistogramFactoryTest : public PlatformTest { public: UrlLanguageHistogramFactoryTest() { TestChromeBrowserState::Builder browser_state_builder; diff --git a/ios/chrome/browser/metrics/ios_chrome_metrics_service_accessor_unittest.cc b/ios/chrome/browser/metrics/ios_chrome_metrics_service_accessor_unittest.cc index e3c3094070ae9d..4e34437e1b692f 100644 --- a/ios/chrome/browser/metrics/ios_chrome_metrics_service_accessor_unittest.cc +++ b/ios/chrome/browser/metrics/ios_chrome_metrics_service_accessor_unittest.cc @@ -13,8 +13,9 @@ #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" #include "ios/chrome/test/testing_application_context.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" -class IOSChromeMetricsServiceAccessorTest : public testing::Test { +class IOSChromeMetricsServiceAccessorTest : public PlatformTest { public: IOSChromeMetricsServiceAccessorTest() {} diff --git a/ios/chrome/browser/metrics/ios_chrome_stability_metrics_provider_unittest.cc b/ios/chrome/browser/metrics/ios_chrome_stability_metrics_provider_unittest.cc index a4399c45a4c38d..966890486df7d6 100644 --- a/ios/chrome/browser/metrics/ios_chrome_stability_metrics_provider_unittest.cc +++ b/ios/chrome/browser/metrics/ios_chrome_stability_metrics_provider_unittest.cc @@ -10,10 +10,11 @@ #include "components/prefs/scoped_user_pref_update.h" #include "components/prefs/testing_pref_service.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" namespace { -class IOSChromeStabilityMetricsProviderTest : public testing::Test { +class IOSChromeStabilityMetricsProviderTest : public PlatformTest { protected: IOSChromeStabilityMetricsProviderTest() : prefs_(new TestingPrefServiceSimple) { diff --git a/ios/chrome/browser/metrics/mobile_session_shutdown_metrics_provider_unittest.mm b/ios/chrome/browser/metrics/mobile_session_shutdown_metrics_provider_unittest.mm index 83c1a84ff0f550..5c49d757606b13 100644 --- a/ios/chrome/browser/metrics/mobile_session_shutdown_metrics_provider_unittest.mm +++ b/ios/chrome/browser/metrics/mobile_session_shutdown_metrics_provider_unittest.mm @@ -19,6 +19,7 @@ #include "components/prefs/testing_pref_service.h" #include "testing/gtest/include/gtest/gtest-param-test.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -67,7 +68,8 @@ bool ReceivedMemoryWarningBeforeLastShutdown() override { }; class MobileSessionShutdownMetricsProviderTest - : public testing::TestWithParam { + : public PlatformTest, + public testing::WithParamInterface { public: MobileSessionShutdownMetricsProviderTest() { metrics::MetricsService::RegisterPrefs(local_state_.registry()); diff --git a/ios/chrome/browser/metrics/previous_session_info_unittest.mm b/ios/chrome/browser/metrics/previous_session_info_unittest.mm index 5168ed023484d3..f991d63994fa1a 100644 --- a/ios/chrome/browser/metrics/previous_session_info_unittest.mm +++ b/ios/chrome/browser/metrics/previous_session_info_unittest.mm @@ -9,6 +9,7 @@ #include "ios/chrome/browser/metrics/previous_session_info_private.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -25,7 +26,9 @@ // last session. NSString* const kLastRanVersion = @"LastRanVersion"; -TEST(PreviousSessionInfoTest, InitializationWithEmptyDefaults) { +using PreviousSessionInfoTest = PlatformTest; + +TEST_F(PreviousSessionInfoTest, InitializationWithEmptyDefaults) { [PreviousSessionInfo resetSharedInstanceForTesting]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults removeObjectForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]; @@ -39,7 +42,7 @@ EXPECT_TRUE([sharedInstance isFirstSessionAfterUpgrade]); } -TEST(PreviousSessionInfoTest, InitializationWithSameVersionNoMemoryWarning) { +TEST_F(PreviousSessionInfoTest, InitializationWithSameVersionNoMemoryWarning) { [PreviousSessionInfo resetSharedInstanceForTesting]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults removeObjectForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]; @@ -58,7 +61,7 @@ EXPECT_FALSE([sharedInstance isFirstSessionAfterUpgrade]); } -TEST(PreviousSessionInfoTest, InitializationWithSameVersionMemoryWarning) { +TEST_F(PreviousSessionInfoTest, InitializationWithSameVersionMemoryWarning) { [PreviousSessionInfo resetSharedInstanceForTesting]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults removeObjectForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]; @@ -80,7 +83,7 @@ EXPECT_FALSE([sharedInstance isFirstSessionAfterUpgrade]); } -TEST(PreviousSessionInfoTest, InitializationDifferentVersionNoMemoryWarning) { +TEST_F(PreviousSessionInfoTest, InitializationDifferentVersionNoMemoryWarning) { [PreviousSessionInfo resetSharedInstanceForTesting]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults removeObjectForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]; @@ -97,7 +100,7 @@ EXPECT_TRUE([sharedInstance isFirstSessionAfterUpgrade]); } -TEST(PreviousSessionInfoTest, InitializationDifferentVersionMemoryWarning) { +TEST_F(PreviousSessionInfoTest, InitializationDifferentVersionMemoryWarning) { [PreviousSessionInfo resetSharedInstanceForTesting]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults removeObjectForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]; @@ -117,7 +120,7 @@ EXPECT_TRUE([sharedInstance isFirstSessionAfterUpgrade]); } -TEST(PreviousSessionInfoTest, BeginRecordingCurrentSession) { +TEST_F(PreviousSessionInfoTest, BeginRecordingCurrentSession) { [PreviousSessionInfo resetSharedInstanceForTesting]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults removeObjectForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]; @@ -137,7 +140,7 @@ [defaults boolForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]); } -TEST(PreviousSessionInfoTest, SetMemoryWarningFlagNoOpUntilRecordingBegins) { +TEST_F(PreviousSessionInfoTest, SetMemoryWarningFlagNoOpUntilRecordingBegins) { [PreviousSessionInfo resetSharedInstanceForTesting]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults removeObjectForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]; @@ -150,7 +153,8 @@ [defaults boolForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]); } -TEST(PreviousSessionInfoTest, ResetMemoryWarningFlagNoOpUntilRecordingBegins) { +TEST_F(PreviousSessionInfoTest, + ResetMemoryWarningFlagNoOpUntilRecordingBegins) { [PreviousSessionInfo resetSharedInstanceForTesting]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults removeObjectForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]; @@ -166,7 +170,7 @@ [defaults boolForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]); } -TEST(PreviousSessionInfoTest, MemoryWarningFlagMethodsAfterRecordingBegins) { +TEST_F(PreviousSessionInfoTest, MemoryWarningFlagMethodsAfterRecordingBegins) { [PreviousSessionInfo resetSharedInstanceForTesting]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults removeObjectForKey:kDidSeeMemoryWarningShortlyBeforeTerminating]; diff --git a/ios/chrome/browser/net/cookie_util_unittest.mm b/ios/chrome/browser/net/cookie_util_unittest.mm index 1597e8d34d59ef..42a2bd917bb5db 100644 --- a/ios/chrome/browser/net/cookie_util_unittest.mm +++ b/ios/chrome/browser/net/cookie_util_unittest.mm @@ -7,6 +7,7 @@ #import #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -19,7 +20,9 @@ } // namespace -TEST(CookieUtil, ShouldClearSessionCookies) { +using CookieUtil = PlatformTest; + +TEST_F(CookieUtil, ShouldClearSessionCookies) { time_t start_test_time; time(&start_test_time); NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; diff --git a/ios/chrome/browser/notification_promo_unittest.cc b/ios/chrome/browser/notification_promo_unittest.cc index 25b68ab103d898..bbadaeb83269b3 100644 --- a/ios/chrome/browser/notification_promo_unittest.cc +++ b/ios/chrome/browser/notification_promo_unittest.cc @@ -21,6 +21,7 @@ #include "components/variations/variations_associated_data.h" #include "ios/chrome/browser/notification_promo.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #include "third_party/icu/source/i18n/unicode/smpdtfmt.h" namespace ios { @@ -47,7 +48,7 @@ bool YearFromNow(double* date_epoch, std::string* date_string) { } // namespace -class NotificationPromoTest : public testing::Test { +class NotificationPromoTest : public PlatformTest { public: NotificationPromoTest() : notification_promo_(&local_state_), diff --git a/ios/chrome/browser/passwords/credential_manager_util_unittest.cc b/ios/chrome/browser/passwords/credential_manager_util_unittest.cc index 872d50906c2ba6..ae4f9819971e5a 100644 --- a/ios/chrome/browser/passwords/credential_manager_util_unittest.cc +++ b/ios/chrome/browser/passwords/credential_manager_util_unittest.cc @@ -47,9 +47,11 @@ base::DictionaryValue BuildExampleValidFederatedCredential() { } // namespace +using CredentialManagerUtilTest = PlatformTest; + // Checks that CredentialRequestOptions.password field is parsed // correctly. -TEST(CredentialManagerUtilTest, ParseIncludePasswords) { +TEST_F(CredentialManagerUtilTest, ParseIncludePasswords) { base::DictionaryValue json; bool include_passwords = true; @@ -73,7 +75,7 @@ TEST(CredentialManagerUtilTest, ParseIncludePasswords) { // Checks that CredentialRequestOptions.mediation field is parsed // correctly. -TEST(CredentialManagerUtilTest, ParseMediationRequirement) { +TEST_F(CredentialManagerUtilTest, ParseMediationRequirement) { base::DictionaryValue json; CredentialMediationRequirement mediation; @@ -100,7 +102,7 @@ TEST(CredentialManagerUtilTest, ParseMediationRequirement) { } // Checks that Credential.type field is parsed correctly. -TEST(CredentialManagerUtilTest, ParseCredentialType) { +TEST_F(CredentialManagerUtilTest, ParseCredentialType) { base::DictionaryValue json; CredentialType type = CredentialType::CREDENTIAL_TYPE_EMPTY; @@ -128,7 +130,7 @@ TEST(CredentialManagerUtilTest, ParseCredentialType) { // Checks that common fields of PasswordCredential and FederatedCredential are // parsed correctly. -TEST(CredentialManagerUtilTest, ParseCommonCredentialFields) { +TEST_F(CredentialManagerUtilTest, ParseCommonCredentialFields) { // Building PasswordCredential because ParseCredentialDictionary for // Credential containing only common fields would return false. base::DictionaryValue json = BuildExampleValidPasswordCredential(); @@ -170,7 +172,7 @@ TEST(CredentialManagerUtilTest, ParseCommonCredentialFields) { // Checks that |password| and |type| fields of PasswordCredential are parsed // correctly. -TEST(CredentialManagerUtilTest, ParsePasswordCredential) { +TEST_F(CredentialManagerUtilTest, ParsePasswordCredential) { base::DictionaryValue json = BuildExampleValidPasswordCredential(); CredentialInfo credential; std::string reason; @@ -194,7 +196,7 @@ TEST(CredentialManagerUtilTest, ParsePasswordCredential) { // Checks that |provider| and |type| fields of FederatedCredential are parsed // correctly. -TEST(CredentialManagerUtilTest, ParseFederatedCredential) { +TEST_F(CredentialManagerUtilTest, ParseFederatedCredential) { base::DictionaryValue json = BuildExampleValidFederatedCredential(); CredentialInfo credential; std::string reason; @@ -223,7 +225,7 @@ TEST(CredentialManagerUtilTest, ParseFederatedCredential) { // Checks that |providers| field of FederatedCredentialRequestOptions is // parsed correctly. -TEST(CredentialManagerUtilTest, ParseFederations) { +TEST_F(CredentialManagerUtilTest, ParseFederations) { base::DictionaryValue json; // Build example valid |providers| list. diff --git a/ios/chrome/browser/passwords/password_controller_unittest.mm b/ios/chrome/browser/passwords/password_controller_unittest.mm index a5299270940183..f3d3718758d676 100644 --- a/ios/chrome/browser/passwords/password_controller_unittest.mm +++ b/ios/chrome/browser/passwords/password_controller_unittest.mm @@ -39,6 +39,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #import "third_party/ocmock/OCMock/OCPartialMockObject.h" #include "url/gurl.h" @@ -1292,9 +1293,11 @@ void SetPasswordFormFillData(PasswordFormFillData& form_data, } } +using PasswordControllerTestSimple = PlatformTest; + // The test case below does not need the heavy fixture from above, but it // needs to use MockWebState. -TEST(PasswordControllerTestSimple, SaveOnNonHTMLLandingPage) { +TEST_F(PasswordControllerTestSimple, SaveOnNonHTMLLandingPage) { base::test::ScopedTaskEnvironment task_environment; TestChromeBrowserState::Builder builder; std::unique_ptr browser_state(builder.Build()); diff --git a/ios/chrome/browser/payments/ios_payment_instrument_finder_unittest.mm b/ios/chrome/browser/payments/ios_payment_instrument_finder_unittest.mm index 4da1ef68c6fd6d..5a3342c696160e 100644 --- a/ios/chrome/browser/payments/ios_payment_instrument_finder_unittest.mm +++ b/ios/chrome/browser/payments/ios_payment_instrument_finder_unittest.mm @@ -13,6 +13,7 @@ #include "net/url_request/url_request_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -35,7 +36,7 @@ DISALLOW_COPY_AND_ASSIGN(TestIOSPaymentInstrumentFinder); }; -class PaymentRequestIOSPaymentInstrumentFinderTest : public testing::Test { +class PaymentRequestIOSPaymentInstrumentFinderTest : public PlatformTest { public: PaymentRequestIOSPaymentInstrumentFinderTest() : scoped_task_environment_( diff --git a/ios/chrome/browser/payments/ios_payment_instrument_launcher_unittest.mm b/ios/chrome/browser/payments/ios_payment_instrument_launcher_unittest.mm index 2ae17aa6350989..a0d1600b64c76e 100644 --- a/ios/chrome/browser/payments/ios_payment_instrument_launcher_unittest.mm +++ b/ios/chrome/browser/payments/ios_payment_instrument_launcher_unittest.mm @@ -22,6 +22,7 @@ #include "ios/web/public/test/fakes/test_navigation_manager.h" #import "ios/web/public/test/fakes/test_web_state.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -71,7 +72,7 @@ void RunLoop() { } // namespace -class PaymentRequestIOSPaymentInstrumentLauncherTest : public testing::Test { +class PaymentRequestIOSPaymentInstrumentLauncherTest : public PlatformTest { protected: PaymentRequestIOSPaymentInstrumentLauncherTest() : chrome_browser_state_(TestChromeBrowserState::Builder().Build()) {} diff --git a/ios/chrome/browser/payments/payment_request_unittest.mm b/ios/chrome/browser/payments/payment_request_unittest.mm index 559aad4f301a8a..51c3463854ff3c 100644 --- a/ios/chrome/browser/payments/payment_request_unittest.mm +++ b/ios/chrome/browser/payments/payment_request_unittest.mm @@ -29,6 +29,7 @@ #include "testing/gmock/include/gmock/gmock-matchers.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -50,7 +51,7 @@ namespace payments { -class PaymentRequestTest : public testing::Test { +class PaymentRequestTest : public PlatformTest { protected: PaymentRequestTest() : chrome_browser_state_(TestChromeBrowserState::Builder().Build()) {} diff --git a/ios/chrome/browser/reading_list/offline_url_utils_unittest.cc b/ios/chrome/browser/reading_list/offline_url_utils_unittest.cc index 0229ceb94bb2ee..60b03dc5393ed4 100644 --- a/ios/chrome/browser/reading_list/offline_url_utils_unittest.cc +++ b/ios/chrome/browser/reading_list/offline_url_utils_unittest.cc @@ -14,11 +14,14 @@ #include "components/reading_list/core/reading_list_entry.h" #include "components/reading_list/core/reading_list_model_impl.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #include "url/gurl.h" +using OfflineURLUtilsTest = PlatformTest; + // Checks the distilled URL for the page with an onlineURL is // chrome://offline/MD5/page.html?entryURL=...&virtualURL=... -TEST(OfflineURLUtilsTest, OfflineURLForPathWithEntryURLAndVirtualURLTest) { +TEST_F(OfflineURLUtilsTest, OfflineURLForPathWithEntryURLAndVirtualURLTest) { base::FilePath page_path("MD5/page.html"); GURL entry_url = GURL("http://foo.bar"); GURL virtual_url = GURL("http://foo.bar/virtual"); @@ -33,7 +36,7 @@ TEST(OfflineURLUtilsTest, OfflineURLForPathWithEntryURLAndVirtualURLTest) { // Checks the parsing of offline URL chrome://offline/MD5/page.html. // As entryURL and virtualURL are absent, they should be invalid. -TEST(OfflineURLUtilsTest, ParseOfflineURLTest) { +TEST_F(OfflineURLUtilsTest, ParseOfflineURLTest) { GURL distilled_url("chrome://offline/MD5/page.html"); GURL entry_url = reading_list::EntryURLForOfflineURL(distilled_url); EXPECT_TRUE(entry_url.is_empty()); @@ -45,7 +48,7 @@ TEST(OfflineURLUtilsTest, ParseOfflineURLTest) { // chrome://offline/MD5/page.html?entryURL=encorded%20URL // As entryURL is present, it should be returned correctly. // As virtualURL is absent, it should return GURL::EmptyGURL(). -TEST(OfflineURLUtilsTest, ParseOfflineURLWithEntryURLTest) { +TEST_F(OfflineURLUtilsTest, ParseOfflineURLWithEntryURLTest) { GURL offline_url( "chrome://offline/MD5/page.html?entryURL=http%3A%2F%2Ffoo.bar%2F"); GURL entry_url = reading_list::EntryURLForOfflineURL(offline_url); @@ -58,7 +61,7 @@ TEST(OfflineURLUtilsTest, ParseOfflineURLWithEntryURLTest) { // chrome://offline/MD5/page.html?virtualURL=encorded%20URL // As entryURL is absent, it should return the offline URL. // As virtualURL is present, it should be returned correctly. -TEST(OfflineURLUtilsTest, ParseOfflineURLWithVirtualURLTest) { +TEST_F(OfflineURLUtilsTest, ParseOfflineURLWithVirtualURLTest) { GURL offline_url( "chrome://offline/MD5/page.html?virtualURL=http%3A%2F%2Ffoo.bar%2F"); GURL entry_url = reading_list::EntryURLForOfflineURL(offline_url); @@ -71,7 +74,7 @@ TEST(OfflineURLUtilsTest, ParseOfflineURLWithVirtualURLTest) { // chrome://offline/MD5/page.html?entryURL=...&virtualURL=... // As entryURL is present, it should be returned correctly. // As virtualURL is present, it should be returned correctly. -TEST(OfflineURLUtilsTest, ParseOfflineURLWithVirtualAndEntryURLTest) { +TEST_F(OfflineURLUtilsTest, ParseOfflineURLWithVirtualAndEntryURLTest) { GURL offline_url( "chrome://offline/MD5/" "page.html?virtualURL=http%3A%2F%2Ffoo.bar%2Fvirtual&entryURL=http%3A%2F%" @@ -86,7 +89,7 @@ TEST(OfflineURLUtilsTest, ParseOfflineURLWithVirtualAndEntryURLTest) { // file://profile_path/Offline/MD5/page.html. // Checks the resource root for chrome://offline/MD5/page.html is // file://profile_path/Offline/MD5 -TEST(OfflineURLUtilsTest, FileURLForDistilledURLTest) { +TEST_F(OfflineURLUtilsTest, FileURLForDistilledURLTest) { base::FilePath offline_path("/profile_path/Offline"); GURL file_url = reading_list::FileURLForDistilledURL(GURL(), offline_path, nullptr); @@ -108,7 +111,7 @@ TEST(OfflineURLUtilsTest, FileURLForDistilledURLTest) { } // Checks that the offline URLs are correctly detected by |IsOfflineURL|. -TEST(OfflineURLUtilsTest, IsOfflineURL) { +TEST_F(OfflineURLUtilsTest, IsOfflineURL) { EXPECT_FALSE(reading_list::IsOfflineURL(GURL())); EXPECT_FALSE(reading_list::IsOfflineURL(GURL("chrome://"))); EXPECT_FALSE(reading_list::IsOfflineURL(GURL("chrome://offline-foobar"))); @@ -122,7 +125,7 @@ TEST(OfflineURLUtilsTest, IsOfflineURL) { } // Checks that the offline URLs are correctly detected by |IsOfflineURL|. -TEST(OfflineURLUtilsTest, IsOfflineURLValid) { +TEST_F(OfflineURLUtilsTest, IsOfflineURLValid) { auto reading_list_model = base::MakeUnique( nullptr, nullptr, base::MakeUnique()); GURL entry_url("http://entry_url.com"); diff --git a/ios/chrome/browser/reading_list/url_downloader_unittest.mm b/ios/chrome/browser/reading_list/url_downloader_unittest.mm index 63355a26c99647..2ebeb3075ea499 100644 --- a/ios/chrome/browser/reading_list/url_downloader_unittest.mm +++ b/ios/chrome/browser/reading_list/url_downloader_unittest.mm @@ -18,6 +18,7 @@ #include "ios/chrome/browser/reading_list/offline_url_utils.h" #include "ios/chrome/browser/reading_list/reading_list_distiller_page.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -137,7 +138,7 @@ void OnEndRemove(const GURL& url, bool success) { }; namespace { -class URLDownloaderTest : public testing::Test { +class URLDownloaderTest : public PlatformTest { public: URLDownloaderTest() { base::FilePath data_dir; diff --git a/ios/chrome/browser/snapshots/lru_cache_unittest.mm b/ios/chrome/browser/snapshots/lru_cache_unittest.mm index 31b322003b9de4..70987da1cf370a 100644 --- a/ios/chrome/browser/snapshots/lru_cache_unittest.mm +++ b/ios/chrome/browser/snapshots/lru_cache_unittest.mm @@ -4,6 +4,7 @@ #import "ios/chrome/browser/snapshots/lru_cache.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -11,7 +12,9 @@ namespace { -TEST(LRUCacheTest, Basic) { +using LRUCacheTest = PlatformTest; + +TEST_F(LRUCacheTest, Basic) { LRUCache* cache = [[LRUCache alloc] initWithCacheSize:3]; NSString* value1 = @"Value 1"; diff --git a/ios/chrome/browser/snapshots/snapshots_util_unittest.mm b/ios/chrome/browser/snapshots/snapshots_util_unittest.mm index 910160d7fd927a..3722add71bf206 100644 --- a/ios/chrome/browser/snapshots/snapshots_util_unittest.mm +++ b/ios/chrome/browser/snapshots/snapshots_util_unittest.mm @@ -12,6 +12,7 @@ #include "base/path_service.h" #include "base/strings/sys_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -39,7 +40,9 @@ bool RegexMatchesOneSnapshotPath(NSString* regexString) { return numberOfMatches == 1; } -TEST(SnapshotsUtilTest, TestSnapshotList) { +using SnapshotsUtilTest = PlatformTest; + +TEST_F(SnapshotsUtilTest, TestSnapshotList) { NSString* scaleModifier = @""; CGFloat scale = [UIScreen mainScreen].scale; if (scale > 1) { diff --git a/ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory_unittest.cc b/ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory_unittest.cc index 62eb0d278309ef..b718fbf93d7c9f 100644 --- a/ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory_unittest.cc +++ b/ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory_unittest.cc @@ -17,10 +17,11 @@ #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" #include "ios/web/public/test/test_web_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" using syncer::DataTypeController; -class IOSChromeProfileSyncServiceFactoryTest : public testing::Test { +class IOSChromeProfileSyncServiceFactoryTest : public PlatformTest { public: IOSChromeProfileSyncServiceFactoryTest() { TestChromeBrowserState::Builder browser_state_builder; diff --git a/ios/chrome/browser/translate/translate_service_ios_unittest.cc b/ios/chrome/browser/translate/translate_service_ios_unittest.cc index 6f7e03253b866c..fbd0d8abb7a315 100644 --- a/ios/chrome/browser/translate/translate_service_ios_unittest.cc +++ b/ios/chrome/browser/translate/translate_service_ios_unittest.cc @@ -7,9 +7,12 @@ #include "ios/chrome/browser/chrome_url_constants.h" #include "ios/public/provider/chrome/browser/test_chrome_provider_initializer.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #include "url/gurl.h" -TEST(TranslateServiceIOSTest, CheckTranslatableURL) { +using TranslateServiceIOSTest = PlatformTest; + +TEST_F(TranslateServiceIOSTest, CheckTranslatableURL) { GURL empty_url = GURL(std::string()); EXPECT_FALSE(TranslateServiceIOS::IsTranslatableURL(empty_url)); diff --git a/ios/chrome/browser/ui/activity_services/activity_type_util_unittest.mm b/ios/chrome/browser/ui/activity_services/activity_type_util_unittest.mm index d7240cfda1e668..178025abaa673f 100644 --- a/ios/chrome/browser/ui/activity_services/activity_type_util_unittest.mm +++ b/ios/chrome/browser/ui/activity_services/activity_type_util_unittest.mm @@ -9,6 +9,7 @@ #include "ios/chrome/grit/ios_strings.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "ui/base/l10n/l10n_util_mac.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -22,7 +23,9 @@ void StringToTypeTestHelper(NSString* activityString, EXPECT_EQ(activity_type_util::TypeFromString(activityString), expectedType); } -TEST(ActivityTypeUtilTest, StringToTypeTest) { +using ActivityTypeUtilTest = PlatformTest; + +TEST_F(ActivityTypeUtilTest, StringToTypeTest) { StringToTypeTestHelper(@"", activity_type_util::UNKNOWN); StringToTypeTestHelper(@"foo", activity_type_util::UNKNOWN); StringToTypeTestHelper(@"com.google", activity_type_util::UNKNOWN); @@ -45,7 +48,7 @@ void TypeToMessageTestHelper(activity_type_util::ActivityType type, expectedMessage); } -TEST(ActivityTypeUtilTest, TypeToMessageTest) { +TEST_F(ActivityTypeUtilTest, TypeToMessageTest) { TypeToMessageTestHelper(activity_type_util::UNKNOWN, nil); TypeToMessageTestHelper(activity_type_util::PRINT, nil); TypeToMessageTestHelper( @@ -56,7 +59,7 @@ void TypeToMessageTestHelper(activity_type_util::ActivityType type, l10n_util::GetNSString(IDS_IOS_APPEX_PASSWORD_FORM_FILLED_SUCCESS)); } -TEST(ActivityTypeUtilTest, IsPasswordAppExtensionTest) { +TEST_F(ActivityTypeUtilTest, IsPasswordAppExtensionTest) { // Verifies that known Bundle ID for 1Password requires exact match. EXPECT_EQ(activity_type_util::APPEX_PASSWORD_MANAGEMENT, activity_type_util::TypeFromString( diff --git a/ios/chrome/browser/ui/activity_services/share_to_data_builder_unittest.mm b/ios/chrome/browser/ui/activity_services/share_to_data_builder_unittest.mm index 7d6e58c2e132d1..c8f1acf13631ea 100644 --- a/ios/chrome/browser/ui/activity_services/share_to_data_builder_unittest.mm +++ b/ios/chrome/browser/ui/activity_services/share_to_data_builder_unittest.mm @@ -12,6 +12,7 @@ #import "ios/web/web_state/web_state_impl.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #import "ui/base/test/ios/ui_image_test_utils.h" @@ -47,8 +48,10 @@ - (void)setWebState:(WebStateImpl*)webState { } @end +using ShareToDataBuilderTest = PlatformTest; + // Verifies that ShareToData is constructed properly for a given Tab. -TEST(ShareToDataBuilderTest, TestSharePageCommandHandling) { +TEST_F(ShareToDataBuilderTest, TestSharePageCommandHandling) { GURL expected_url("http://www.testurl.net"); NSString* expected_title = @"title"; @@ -94,7 +97,7 @@ - (void)setWebState:(WebStateImpl*)webState { // Verifies that |ShareToDataForTab()| returns nil if the Tab is in the process // of being closed. -TEST(ShareToDataBuilderTest, TestReturnsNilWhenClosing) { +TEST_F(ShareToDataBuilderTest, TestReturnsNilWhenClosing) { GURL expected_url("http://www.testurl.net"); NSString* expected_title = @"title"; diff --git a/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator_unittest.mm b/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator_unittest.mm index 9437ff3dfb88a5..a935e35c3fc011 100644 --- a/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator_unittest.mm @@ -14,8 +14,10 @@ #error "This file requires ARC support." #endif +using ActionSheetCoordinatorTest = PlatformTest; + // Tests that if there is a popover, it uses the CGRect passed in init. -TEST(ActionSheetCoordinatorTest, CGRectUsage) { +TEST_F(ActionSheetCoordinatorTest, CGRectUsage) { ScopedKeyWindow scoped_key_window; UIViewController* viewController = [[UIViewController alloc] init]; [scoped_key_window.Get() setRootViewController:viewController]; diff --git a/ios/chrome/browser/ui/alert_coordinator/input_alert_coordinator_unittest.mm b/ios/chrome/browser/ui/alert_coordinator/input_alert_coordinator_unittest.mm index 5cbf9325c703bc..2c4bd184948ea2 100644 --- a/ios/chrome/browser/ui/alert_coordinator/input_alert_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/alert_coordinator/input_alert_coordinator_unittest.mm @@ -12,7 +12,9 @@ #error "This file requires ARC support." #endif -TEST(InputAlertCoordinatorTest, AddTextField) { +using InputAlertCoordinatorTest = PlatformTest; + +TEST_F(InputAlertCoordinatorTest, AddTextField) { // Setup. UIViewController* viewController = [[UIViewController alloc] init]; InputAlertCoordinator* alertCoordinator = @@ -33,7 +35,7 @@ EXPECT_OCMOCK_VERIFY(alert); } -TEST(InputAlertCoordinatorTest, GetTextFields) { +TEST_F(InputAlertCoordinatorTest, GetTextFields) { // Setup. UIViewController* viewController = [[UIViewController alloc] init]; InputAlertCoordinator* alertCoordinator = diff --git a/ios/chrome/browser/ui/authentication/account_control_item_unittest.mm b/ios/chrome/browser/ui/authentication/account_control_item_unittest.mm index f4aa9a874c5f48..4b8dda427c1ce7 100644 --- a/ios/chrome/browser/ui/authentication/account_control_item_unittest.mm +++ b/ios/chrome/browser/ui/authentication/account_control_item_unittest.mm @@ -7,14 +7,17 @@ #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using AccountControlItemTest = PlatformTest; + // Tests that the cell is properly configured with image and texts after a call // to |configureCell:|. All other cell decorations are default. -TEST(AccountControlItemTest, ConfigureCellDefault) { +TEST_F(AccountControlItemTest, ConfigureCellDefault) { AccountControlItem* item = [[AccountControlItem alloc] initWithType:0]; UIImage* image = [[UIImage alloc] init]; NSString* mainText = @"Main text"; @@ -47,7 +50,7 @@ // Tests that the cell is properly configured with error and an accessory after // a call to |configureCell:|. -TEST(AccountControlItemTest, ConfigureCellWithErrorAndAccessory) { +TEST_F(AccountControlItemTest, ConfigureCellWithErrorAndAccessory) { AccountControlItem* item = [[AccountControlItem alloc] initWithType:0]; UIImage* image = [[UIImage alloc] init]; NSString* mainText = @"Main text"; diff --git a/ios/chrome/browser/ui/authentication/authentication_ui_util_unittest.mm b/ios/chrome/browser/ui/authentication/authentication_ui_util_unittest.mm index eea49593d1a28b..a7e829b159c841 100644 --- a/ios/chrome/browser/ui/authentication/authentication_ui_util_unittest.mm +++ b/ios/chrome/browser/ui/authentication/authentication_ui_util_unittest.mm @@ -24,8 +24,10 @@ void ExpectErrorInMessage(NSError* error, } } +using AuthenticationUIUtil = PlatformTest; + // Tests the error message with one error with a localized description. -TEST(AuthenticationUIUtil, DialogMessageFromErrorWithLocalizedDescription) { +TEST_F(AuthenticationUIUtil, DialogMessageFromErrorWithLocalizedDescription) { NSDictionary* userInfo = @{NSLocalizedDescriptionKey : @"MyLocalizedDescription"}; NSError* error = @@ -35,7 +37,8 @@ void ExpectErrorInMessage(NSError* error, } // Tests the error message with one error without a localized description. -TEST(AuthenticationUIUtil, DialogMessageFromErrorWithoutLocalizedDescription) { +TEST_F(AuthenticationUIUtil, + DialogMessageFromErrorWithoutLocalizedDescription) { NSError* error = [NSError errorWithDomain:@"MyErrorDomain" code:-1234 userInfo:nil]; NSString* message = DialogMessageFromError(error); @@ -43,7 +46,7 @@ void ExpectErrorInMessage(NSError* error, } // Tests the error message with an error with 2 underlying errors. -TEST(AuthenticationUIUtil, DialogMessageFromErrorWithUnderlyingErrors) { +TEST_F(AuthenticationUIUtil, DialogMessageFromErrorWithUnderlyingErrors) { // Error 1 NSDictionary* userInfo1 = @{NSLocalizedDescriptionKey : @"MyLocalizedDescription1"}; diff --git a/ios/chrome/browser/ui/authentication/signin_promo_item_unittest.mm b/ios/chrome/browser/ui/authentication/signin_promo_item_unittest.mm index 60a81c746d15a7..8cff547891e1a3 100644 --- a/ios/chrome/browser/ui/authentication/signin_promo_item_unittest.mm +++ b/ios/chrome/browser/ui/authentication/signin_promo_item_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/authentication/signin_promo_view.h" #import "ios/chrome/browser/ui/authentication/signin_promo_view_configurator.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #include "third_party/ocmock/gtest_support.h" @@ -14,8 +15,10 @@ #error "This file requires ARC support." #endif +using SigninPromoItemTest = PlatformTest; + // Tests that SigninPromoItem creates and configures correctly SigninPromoCell. -TEST(SigninPromoItemTest, ConfigureCell) { +TEST_F(SigninPromoItemTest, ConfigureCell) { SigninPromoViewConfigurator* configurator = OCMStrictClassMock([SigninPromoViewConfigurator class]); SigninPromoItem* item = [[SigninPromoItem alloc] initWithType:0]; diff --git a/ios/chrome/browser/ui/authentication/signin_promo_view_unittest.mm b/ios/chrome/browser/ui/authentication/signin_promo_view_unittest.mm index cae39c49c02cf1..99bf5b4e27a659 100644 --- a/ios/chrome/browser/ui/authentication/signin_promo_view_unittest.mm +++ b/ios/chrome/browser/ui/authentication/signin_promo_view_unittest.mm @@ -5,13 +5,16 @@ #import "ios/chrome/browser/ui/authentication/signin_promo_view.h" #import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h" +#include "testing/platform_test.h" #include "third_party/ocmock/gtest_support.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif -TEST(SigninPromoViewTest, ChromiumLogoImage) { +using SigninPromoViewTest = PlatformTest; + +TEST_F(SigninPromoViewTest, ChromiumLogoImage) { SigninPromoView* view = [[SigninPromoView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; view.mode = SigninPromoViewModeColdState; @@ -28,7 +31,7 @@ EXPECT_NE(customImage, view.imageView.image); } -TEST(SigninPromoViewTest, SecondaryButtonVisibility) { +TEST_F(SigninPromoViewTest, SecondaryButtonVisibility) { SigninPromoView* view = [[SigninPromoView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; view.mode = SigninPromoViewModeColdState; diff --git a/ios/chrome/browser/ui/autofill/cells/autofill_edit_item_unittest.mm b/ios/chrome/browser/ui/autofill/cells/autofill_edit_item_unittest.mm index a11f7267272a4d..ed34ad3d02f97f 100644 --- a/ios/chrome/browser/ui/autofill/cells/autofill_edit_item_unittest.mm +++ b/ios/chrome/browser/ui/autofill/cells/autofill_edit_item_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,9 +14,11 @@ namespace { +using AutofillEditItemTest = PlatformTest; + // Tests that the label and text field are set properly after a call to // |configureCell:|. -TEST(AutofillEditItemTest, ConfigureCell) { +TEST_F(AutofillEditItemTest, ConfigureCell) { AutofillEditItem* item = [[AutofillEditItem alloc] initWithType:0]; NSString* name = @"Name"; NSString* value = @"Value"; diff --git a/ios/chrome/browser/ui/autofill/cells/cvc_item_unittest.mm b/ios/chrome/browser/ui/autofill/cells/cvc_item_unittest.mm index d6ee18bf466b60..a473568bfcd8fb 100644 --- a/ios/chrome/browser/ui/autofill/cells/cvc_item_unittest.mm +++ b/ios/chrome/browser/ui/autofill/cells/cvc_item_unittest.mm @@ -8,6 +8,7 @@ #include "components/grit/components_scaled_resources.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -19,9 +20,11 @@ @interface CVCCell (Private) namespace { +using CVCItemTest = PlatformTest; + // Tests that the cell subviews are set properly after a call to // |configureCell:| in the different states possible. -TEST(CVCItemTest, ConfigureCell) { +TEST_F(CVCItemTest, ConfigureCell) { CVCItem* item = [[CVCItem alloc] initWithType:0]; NSString* instructionsText = @"Instructions Test Text"; NSString* errorMessage = @"Test Error Message"; diff --git a/ios/chrome/browser/ui/autofill/cells/status_item_unittest.mm b/ios/chrome/browser/ui/autofill/cells/status_item_unittest.mm index f6c494b7cf8349..ac027650880e2c 100644 --- a/ios/chrome/browser/ui/autofill/cells/status_item_unittest.mm +++ b/ios/chrome/browser/ui/autofill/cells/status_item_unittest.mm @@ -8,6 +8,7 @@ #import "ios/third_party/material_components_ios/src/components/ActivityIndicator/src/MaterialActivityIndicator.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -15,9 +16,11 @@ namespace { +using StatusItemTest = PlatformTest; + // Tests that the cell subviews are set properly after a call to // |configureCell:| in the different states. -TEST(StatusItemTest, ConfigureCell) { +TEST_F(StatusItemTest, ConfigureCell) { StatusItem* item = [[StatusItem alloc] initWithType:0]; NSString* text = @"Test Text"; item.text = text; diff --git a/ios/chrome/browser/ui/autofill/cells/storage_switch_item_unittest.mm b/ios/chrome/browser/ui/autofill/cells/storage_switch_item_unittest.mm index bb2aed40e2c100..d311112b22b65e 100644 --- a/ios/chrome/browser/ui/autofill/cells/storage_switch_item_unittest.mm +++ b/ios/chrome/browser/ui/autofill/cells/storage_switch_item_unittest.mm @@ -6,6 +6,7 @@ #include "base/mac/foundation_util.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,9 +14,11 @@ namespace { +using StorageSwitchItemTest = PlatformTest; + // Tests that the label and switch values are set properly after a call to // |configureCell:|. -TEST(StorageSwitchItemTest, ConfigureCell) { +TEST_F(StorageSwitchItemTest, ConfigureCell) { StorageSwitchItem* item = [[StorageSwitchItem alloc] initWithType:0]; item.on = YES; @@ -31,7 +34,7 @@ EXPECT_TRUE(switchCell.switchView.on); } -TEST(StorageSwitchItemTest, PrepareForReuseClearsActions) { +TEST_F(StorageSwitchItemTest, PrepareForReuseClearsActions) { StorageSwitchCell* cell = [[StorageSwitchCell alloc] init]; UIButton* tooltipButton = cell.tooltipButton; UISwitch* switchView = cell.switchView; diff --git a/ios/chrome/browser/ui/bookmarks/bookmark_path_cache_unittest.mm b/ios/chrome/browser/ui/bookmarks/bookmark_path_cache_unittest.mm index 24649f495e8770..478e4d1f13759f 100644 --- a/ios/chrome/browser/ui/bookmarks/bookmark_path_cache_unittest.mm +++ b/ios/chrome/browser/ui/bookmarks/bookmark_path_cache_unittest.mm @@ -5,6 +5,7 @@ #include "ios/chrome/browser/ui/bookmarks/bookmark_path_cache.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -12,7 +13,9 @@ namespace { -TEST(BookmarkPathCacheTest, TestEquality) { +using BookmarkPathCacheTest = PlatformTest; + +TEST_F(BookmarkPathCacheTest, TestEquality) { BookmarkPathCache* cache = [BookmarkPathCache cacheForBookmarkFolder:57 position:200]; diff --git a/ios/chrome/browser/ui/bookmarks/bookmark_position_cache_unittest.mm b/ios/chrome/browser/ui/bookmarks/bookmark_position_cache_unittest.mm index 89d4cd7a83ad56..acfbf258cd44e0 100644 --- a/ios/chrome/browser/ui/bookmarks/bookmark_position_cache_unittest.mm +++ b/ios/chrome/browser/ui/bookmarks/bookmark_position_cache_unittest.mm @@ -5,6 +5,7 @@ #include "ios/chrome/browser/ui/bookmarks/bookmark_position_cache.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -12,7 +13,9 @@ namespace { -TEST(BookmarkPositionCacheTest, TestMenuItemFolderCoding) { +using BookmarkPositionCacheTest = PlatformTest; + +TEST_F(BookmarkPositionCacheTest, TestMenuItemFolderCoding) { BookmarkPositionCache* cache = [BookmarkPositionCache cacheForMenuItemFolderWithPosition:1010101 folderId:6363]; diff --git a/ios/chrome/browser/ui/bookmarks/cells/bookmark_parent_folder_item_unittest.mm b/ios/chrome/browser/ui/bookmarks/cells/bookmark_parent_folder_item_unittest.mm index db831fb74c086d..cd6d122066d6b7 100644 --- a/ios/chrome/browser/ui/bookmarks/cells/bookmark_parent_folder_item_unittest.mm +++ b/ios/chrome/browser/ui/bookmarks/cells/bookmark_parent_folder_item_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,7 +15,9 @@ namespace { -TEST(BookmarkParentFolderItemTest, LabelGetsTitle) { +using BookmarkParentFolderItemTest = PlatformTest; + +TEST_F(BookmarkParentFolderItemTest, LabelGetsTitle) { BookmarkParentFolderItem* item = [[BookmarkParentFolderItem alloc] initWithType:0]; BookmarkParentFolderCell* cell = diff --git a/ios/chrome/browser/ui/bookmarks/cells/bookmark_text_field_item_unittest.mm b/ios/chrome/browser/ui/bookmarks/cells/bookmark_text_field_item_unittest.mm index 2c680bc7380901..239c1edd152a87 100644 --- a/ios/chrome/browser/ui/bookmarks/cells/bookmark_text_field_item_unittest.mm +++ b/ios/chrome/browser/ui/bookmarks/cells/bookmark_text_field_item_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "third_party/ocmock/OCMock/OCMock.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -14,7 +15,9 @@ namespace { -TEST(BookmarkTextFieldItemTest, DelegateGetsTextFieldEvents) { +using BookmarkTextFieldItemTest = PlatformTest; + +TEST_F(BookmarkTextFieldItemTest, DelegateGetsTextFieldEvents) { BookmarkTextFieldItem* item = [[BookmarkTextFieldItem alloc] initWithType:0]; BookmarkTextFieldCell* cell = [[BookmarkTextFieldCell alloc] initWithFrame:CGRectZero]; @@ -29,7 +32,7 @@ cell.textField.text = @"Foo"; } -TEST(BookmarkTextFieldItemTest, TextFieldGetsText) { +TEST_F(BookmarkTextFieldItemTest, TextFieldGetsText) { BookmarkTextFieldItem* item = [[BookmarkTextFieldItem alloc] initWithType:0]; BookmarkTextFieldCell* cell = [[BookmarkTextFieldCell alloc] initWithFrame:CGRectZero]; diff --git a/ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome_unittest.mm b/ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome_unittest.mm index 471e6f7ad88a89..978739568579e2 100644 --- a/ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome_unittest.mm +++ b/ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item.h" #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -32,7 +33,9 @@ - (void)configureCell:(MDCCollectionViewCell*)cell { namespace { -TEST(MDCCollectionViewCellChrome, PreferredHeightCallsConfigureCell) { +using MDCCollectionViewCellChrome = PlatformTest; + +TEST_F(MDCCollectionViewCellChrome, PreferredHeightCallsConfigureCell) { FakeCollectionViewItem* item = [[FakeCollectionViewItem alloc] initWithType:0]; item.cellClass = [FakeCollectionViewCell class]; @@ -43,7 +46,7 @@ - (void)configureCell:(MDCCollectionViewCell*)cell { EXPECT_EQ(1, item.configureCount); } -TEST(MDCCollectionViewCellChrome, PreferredHeight) { +TEST_F(MDCCollectionViewCellChrome, PreferredHeight) { CollectionViewFooterItem* footerItem = [[CollectionViewFooterItem alloc] initWithType:0]; footerItem.text = @"This is a pretty lengthy sentence."; diff --git a/ios/chrome/browser/ui/collection_view/cells/activity_indicator_cell_unittest.mm b/ios/chrome/browser/ui/collection_view/cells/activity_indicator_cell_unittest.mm index f243a9a4f52ca8..4bd5640349bb21 100644 --- a/ios/chrome/browser/ui/collection_view/cells/activity_indicator_cell_unittest.mm +++ b/ios/chrome/browser/ui/collection_view/cells/activity_indicator_cell_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" #import "ios/third_party/material_components_ios/src/components/ActivityIndicator/src/MaterialActivityIndicator.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,9 +15,11 @@ namespace { +using ActivityIndicatorItemTest = PlatformTest; + // Tests that when an ActivityIndicatorCell is configured, it has a // MDCActivityIndicator that is animating. -TEST(ActivityIndicatorItemTest, CellDisplaysActivityIndicator) { +TEST_F(ActivityIndicatorItemTest, CellDisplaysActivityIndicator) { CollectionViewItem* item = [[CollectionViewItem alloc] initWithType:0]; item.cellClass = [ActivityIndicatorCell class]; ActivityIndicatorCell* cell = diff --git a/ios/chrome/browser/ui/collection_view/cells/collection_view_account_item_unittest.mm b/ios/chrome/browser/ui/collection_view/cells/collection_view_account_item_unittest.mm index b729393aa31d65..27856664c49c3e 100644 --- a/ios/chrome/browser/ui/collection_view/cells/collection_view_account_item_unittest.mm +++ b/ios/chrome/browser/ui/collection_view/cells/collection_view_account_item_unittest.mm @@ -9,14 +9,17 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using AccountControlCollectionViewItemTest = PlatformTest; + // Tests that the UIImageView and UILabels are set properly after a call to // |configureCell:|. -TEST(AccountControlCollectionViewItemTest, ImageViewAndTextLabels) { +TEST_F(AccountControlCollectionViewItemTest, ImageViewAndTextLabels) { CollectionViewAccountItem* item = [[CollectionViewAccountItem alloc] initWithType:0]; UIImage* image = [[UIImage alloc] init]; diff --git a/ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item_unittest.mm b/ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item_unittest.mm index 970a3b58ed33eb..8607b4a4187679 100644 --- a/ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item_unittest.mm +++ b/ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,8 +14,10 @@ namespace { +using CollectionViewDetailItemTest = PlatformTest; + // Tests that the UILabels are set properly after a call to |configureCell:|. -TEST(CollectionViewDetailItemTest, TextLabels) { +TEST_F(CollectionViewDetailItemTest, TextLabels) { CollectionViewDetailItem* item = [[CollectionViewDetailItem alloc] initWithType:0]; NSString* mainText = @"Main text"; @@ -35,9 +38,11 @@ EXPECT_NSEQ(detailText, detailCell.detailTextLabel.text); } +using CollectionViewDetailCellTest = PlatformTest; + // Tests that each of the two text labels is provided with the correct amount // of space. -TEST(CollectionViewDetailCellTest, TextLabelTargetWidths) { +TEST_F(CollectionViewDetailCellTest, TextLabelTargetWidths) { // Make the cell 148 wide so that after allocating 3 * kHorizontalPadding (16) // space for the margins and area between the labels, there is 100 available. // Accordingly, in each of the cases below where the sum of the desired label diff --git a/ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item_unittest.mm b/ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item_unittest.mm index a7711bd7100ea4..a04dc0695ef84a 100644 --- a/ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item_unittest.mm +++ b/ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,9 +15,11 @@ namespace { +using CollectionViewFooterItemTest = PlatformTest; + // Tests that the text label and the image are set properly after a call to // |configureCell:|. -TEST(CollectionViewFooterItemTest, ConfigureCell) { +TEST_F(CollectionViewFooterItemTest, ConfigureCell) { CollectionViewFooterItem* item = [[CollectionViewFooterItem alloc] initWithType:0]; NSString* text = @"Test Footer"; diff --git a/ios/chrome/browser/ui/collection_view/cells/collection_view_item_unittest.mm b/ios/chrome/browser/ui/collection_view/cells/collection_view_item_unittest.mm index 2a9534f4cb7b7b..fa1fe97cbc9978 100644 --- a/ios/chrome/browser/ui/collection_view/cells/collection_view_item_unittest.mm +++ b/ios/chrome/browser/ui/collection_view/cells/collection_view_item_unittest.mm @@ -8,6 +8,7 @@ #import "ios/third_party/material_components_ios/src/components/CollectionCells/src/MaterialCollectionCells.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -15,7 +16,9 @@ namespace { -TEST(CollectionViewItemTest, Accessors) { +using CollectionViewItemTest = PlatformTest; + +TEST_F(CollectionViewItemTest, Accessors) { CollectionViewItem* five = [[CollectionViewItem alloc] initWithType:5]; CollectionViewItem* twelve = [[CollectionViewItem alloc] initWithType:12]; @@ -30,7 +33,7 @@ EXPECT_EQ(1212, [twelve type]); } -TEST(CollectionViewItemTest, ConfigureCellPortsAccessibilityProperties) { +TEST_F(CollectionViewItemTest, ConfigureCellPortsAccessibilityProperties) { CollectionViewItem* item = [[CollectionViewItem alloc] initWithType:0]; item.accessibilityIdentifier = @"test_identifier"; item.accessibilityTraits = UIAccessibilityTraitButton; diff --git a/ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item_unittest.mm b/ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item_unittest.mm index 65bb7b4dc557ed..fbdcb4ab3fcaf1 100644 --- a/ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item_unittest.mm +++ b/ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,9 +14,11 @@ namespace { +using CollectionViewSwitchItemTest = PlatformTest; + // Tests that the label and switch values are set properly after a call to // |configureCell:|. -TEST(CollectionViewSwitchItemTest, ConfigureCell) { +TEST_F(CollectionViewSwitchItemTest, ConfigureCell) { CollectionViewSwitchItem* item = [[CollectionViewSwitchItem alloc] initWithType:0]; NSString* text = @"Test Switch"; @@ -38,7 +41,7 @@ // Tests that the text color and enabled state of the switch are set correctly // by a call to |configureCell:|. -TEST(CollectionViewSwitchItemTest, EnabledAndDisabled) { +TEST_F(CollectionViewSwitchItemTest, EnabledAndDisabled) { CollectionViewSwitchCell* cell = [[CollectionViewSwitchCell alloc] init]; CollectionViewSwitchItem* item = [[CollectionViewSwitchItem alloc] initWithType:0]; @@ -80,7 +83,7 @@ EXPECT_NSEQ(disabledColor, cell.textLabel.textColor); } -TEST(CollectionViewSwitchItemTest, PrepareForReuseClearsActions) { +TEST_F(CollectionViewSwitchItemTest, PrepareForReuseClearsActions) { CollectionViewSwitchCell* cell = [[CollectionViewSwitchCell alloc] init]; UISwitch* switchView = cell.switchView; NSArray* target = [NSArray array]; diff --git a/ios/chrome/browser/ui/collection_view/cells/collection_view_text_item_unittest.mm b/ios/chrome/browser/ui/collection_view/cells/collection_view_text_item_unittest.mm index 60d49c28fade86..8111772a468b44 100644 --- a/ios/chrome/browser/ui/collection_view/cells/collection_view_text_item_unittest.mm +++ b/ios/chrome/browser/ui/collection_view/cells/collection_view_text_item_unittest.mm @@ -11,6 +11,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -18,8 +19,10 @@ namespace { +using CollectionViewTextItemTest = PlatformTest; + // Test that accessory type is copied over to the cell from the item. -TEST(CollectionViewTextItemTest, ConfigureCellPortsAccessoryType) { +TEST_F(CollectionViewTextItemTest, ConfigureCellPortsAccessoryType) { CollectionViewTextItem* item = [[CollectionViewTextItem alloc] initWithType:0]; item.accessoryType = MDCCollectionViewCellAccessoryCheckmark; @@ -31,7 +34,7 @@ } // Test that text properties are copied over to the cell from the item. -TEST(CollectionViewTextItemTest, ConfigureCellPortsTextCellProperties) { +TEST_F(CollectionViewTextItemTest, ConfigureCellPortsTextCellProperties) { CollectionViewTextItem* item = [[CollectionViewTextItem alloc] initWithType:0]; item.text = @"some text"; @@ -47,7 +50,7 @@ // Test that if the item has no accessibilityLabel, the cell gets one composed // of the text and detailText. -TEST(CollectionViewTextItemTest, ConfigureCellDerivesAccessibilityLabel) { +TEST_F(CollectionViewTextItemTest, ConfigureCellDerivesAccessibilityLabel) { CollectionViewTextItem* item = [[CollectionViewTextItem alloc] initWithType:0]; item.text = @"some text"; @@ -61,7 +64,7 @@ // Test that if the item has a non-empty accessibilityLabel, this is copied // over to the cell. -TEST(CollectionViewTextItemTest, ConfigureCellPortsAccessibilityLabel) { +TEST_F(CollectionViewTextItemTest, ConfigureCellPortsAccessibilityLabel) { CollectionViewTextItem* item = [[CollectionViewTextItem alloc] initWithType:0]; item.accessibilityLabel = @"completely different label"; diff --git a/ios/chrome/browser/ui/collection_view/collection_view_model_unittest.mm b/ios/chrome/browser/ui/collection_view/collection_view_model_unittest.mm index 1f1144b8f1ab73..133301368ca5c9 100644 --- a/ios/chrome/browser/ui/collection_view/collection_view_model_unittest.mm +++ b/ios/chrome/browser/ui/collection_view/collection_view_model_unittest.mm @@ -11,6 +11,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -64,8 +65,10 @@ void LogSink(const char* file, // No-op. } +using CollectionViewModelTest = PlatformTest; + // Test generic model boxing (check done at compilation time). -TEST(CollectionViewModelTest, GenericModelBoxing) { +TEST_F(CollectionViewModelTest, GenericModelBoxing) { CollectionViewModel* specificModel = [[CollectionViewModel alloc] init]; @@ -76,7 +79,7 @@ void LogSink(const char* file, generalModel = nil; } -TEST(CollectionViewModelTest, EmptyModel) { +TEST_F(CollectionViewModelTest, EmptyModel) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; // Check there are no items. @@ -87,7 +90,7 @@ void LogSink(const char* file, EXPECT_EQ(0, [model numberOfSections]); } -TEST(CollectionViewModelTest, SingleSection) { +TEST_F(CollectionViewModelTest, SingleSection) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -129,7 +132,7 @@ void LogSink(const char* file, inSection:0]]); } -TEST(CollectionViewModelTest, SingleSectionWithMissingItems) { +TEST_F(CollectionViewModelTest, SingleSectionWithMissingItems) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -148,7 +151,7 @@ void LogSink(const char* file, inSection:0]]); } -TEST(CollectionViewModelTest, MultipleSections) { +TEST_F(CollectionViewModelTest, MultipleSections) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -185,7 +188,7 @@ void LogSink(const char* file, inSection:1]]); } -TEST(CollectionViewModelTest, GetIndexPathFromModelCoordinates) { +TEST_F(CollectionViewModelTest, GetIndexPathFromModelCoordinates) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -212,7 +215,7 @@ void LogSink(const char* file, EXPECT_EQ(0, indexPath.item); } -TEST(CollectionViewItemTest, RepeatedItems) { +TEST_F(CollectionViewModelTest, RepeatedItems) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -245,7 +248,7 @@ void LogSink(const char* file, EXPECT_EQ(2, indexPath.item); } -TEST(CollectionViewModelTest, RepeatedItemIndex) { +TEST_F(CollectionViewModelTest, RepeatedItemIndex) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -280,7 +283,7 @@ void LogSink(const char* file, inSection:1]]); } -TEST(CollectionViewModelTest, RetrieveAddedItem) { +TEST_F(CollectionViewModelTest, RetrieveAddedItem) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -293,7 +296,7 @@ void LogSink(const char* file, inSection:0]]); } -TEST(CollectionViewModelTest, RetrieveItemsInSection) { +TEST_F(CollectionViewModelTest, RetrieveItemsInSection) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; CollectionViewItem* cheddar = @@ -314,7 +317,7 @@ void LogSink(const char* file, EXPECT_NSEQ(gouda, cheeseItems[2]); } -TEST(CollectionViewModelTest, InvalidIndexPath) { +TEST_F(CollectionViewModelTest, InvalidIndexPath) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -331,7 +334,7 @@ void LogSink(const char* file, EXPECT_TRUE(out_of_bounds_exception_thrown); } -TEST(CollectionViewModelTest, RemoveItems) { +TEST_F(CollectionViewModelTest, RemoveItems) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -383,7 +386,7 @@ void LogSink(const char* file, EXPECT_EQ(2, indexPath.item); } -TEST(CollectionViewModelTest, RemoveSections) { +TEST_F(CollectionViewModelTest, RemoveSections) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; // Empty section. @@ -415,7 +418,7 @@ void LogSink(const char* file, EXPECT_EQ(0, [model numberOfSections]); } -TEST(CollectionViewModelTest, QueryItemsFromModelCoordinates) { +TEST_F(CollectionViewModelTest, QueryItemsFromModelCoordinates) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; EXPECT_FALSE([model hasSectionForSectionIdentifier:SectionIdentifierWeasley]); @@ -445,7 +448,7 @@ void LogSink(const char* file, } // Tests that inserted sections are added at the correct index. -TEST(CollectionViewModelTest, InsertSections) { +TEST_F(CollectionViewModelTest, InsertSections) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierWeasley]; @@ -465,7 +468,7 @@ void LogSink(const char* file, } // Tests that inserted items are added at the correct index. -TEST(CollectionViewModelTest, InsertItemAtIndex) { +TEST_F(CollectionViewModelTest, InsertItemAtIndex) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -500,7 +503,7 @@ void LogSink(const char* file, EXPECT_EQ(2, goudaIndexPath.item); } -TEST(CollectionViewModelTest, IndexPathsForItems) { +TEST_F(CollectionViewModelTest, IndexPathsForItems) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierWeasley]; @@ -539,7 +542,7 @@ void LogSink(const char* file, EXPECT_FALSE([model hasItem:notAddedItem]); } -TEST(CollectionViewModelTest, Headers) { +TEST_F(CollectionViewModelTest, Headers) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; @@ -570,7 +573,7 @@ void LogSink(const char* file, EXPECT_FALSE([model headerForSection:weasleySection]); } -TEST(CollectionViewModelTest, Footers) { +TEST_F(CollectionViewModelTest, Footers) { CollectionViewModel* model = [[CollectionViewModel alloc] init]; [model addSectionWithIdentifier:SectionIdentifierCheese]; diff --git a/ios/chrome/browser/ui/commands/command_dispatcher_unittest.mm b/ios/chrome/browser/ui/commands/command_dispatcher_unittest.mm index ce8511e7509aac..1456222f7c9a02 100644 --- a/ios/chrome/browser/ui/commands/command_dispatcher_unittest.mm +++ b/ios/chrome/browser/ui/commands/command_dispatcher_unittest.mm @@ -10,6 +10,7 @@ #import "ios/chrome/browser/ui/metrics/metrics_recorder.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -153,8 +154,10 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { #pragma mark - Tests +using CommandDispatcherTest = PlatformTest; + // Tests handler methods with no arguments. -TEST(CommandDispatcherTest, SimpleTarget) { +TEST_F(CommandDispatcherTest, SimpleTarget) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestSimpleTarget* target = [[CommandDispatcherTestSimpleTarget alloc] init]; @@ -173,7 +176,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { } // Tests handler methods that take arguments. -TEST(CommandDispatcherTest, TargetWithArguments) { +TEST_F(CommandDispatcherTest, TargetWithArguments) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestTargetWithArguments* target = [[CommandDispatcherTestTargetWithArguments alloc] init]; @@ -207,7 +210,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { // Tests that messages are routed to the proper handler when multiple targets // are registered. -TEST(CommandDispatcherTest, MultipleTargets) { +TEST_F(CommandDispatcherTest, MultipleTargets) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestSimpleTarget* showTarget = [[CommandDispatcherTestSimpleTarget alloc] init]; @@ -228,7 +231,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { } // Tests handlers registered via protocols. -TEST(CommandDispatcherTest, ProtocolRegistration) { +TEST_F(CommandDispatcherTest, ProtocolRegistration) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestSimpleTarget* target = [[CommandDispatcherTestSimpleTarget alloc] init]; @@ -244,7 +247,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { // Tests that handlers are no longer forwarded messages after selector // deregistration. -TEST(CommandDispatcherTest, SelectorDeregistration) { +TEST_F(CommandDispatcherTest, SelectorDeregistration) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestSimpleTarget* target = [[CommandDispatcherTestSimpleTarget alloc] init]; @@ -274,7 +277,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { // Tests that handlers are no longer forwarded messages after protocol // deregistration. -TEST(CommandDispatcherTest, ProtocolDeregistration) { +TEST_F(CommandDispatcherTest, ProtocolDeregistration) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestSimpleTarget* target = [[CommandDispatcherTestSimpleTarget alloc] init]; @@ -320,7 +323,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { // Tests that handlers are no longer forwarded messages after target // deregistration. -TEST(CommandDispatcherTest, TargetDeregistration) { +TEST_F(CommandDispatcherTest, TargetDeregistration) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestSimpleTarget* showTarget = [[CommandDispatcherTestSimpleTarget alloc] init]; @@ -351,7 +354,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { // Tests that an exception is thrown when there is no registered handler for a // given selector. -TEST(CommandDispatcherTest, NoTargetRegisteredForSelector) { +TEST_F(CommandDispatcherTest, NoTargetRegisteredForSelector) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestSimpleTarget* target = [[CommandDispatcherTestSimpleTarget alloc] init]; @@ -372,7 +375,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { // Tests that -respondsToSelector returns YES for methods once they are // dispatched for. // Tests handler methods with no arguments. -TEST(CommandDispatcherTest, RespondsToSelector) { +TEST_F(CommandDispatcherTest, RespondsToSelector) { id dispatcher = [[CommandDispatcher alloc] init]; EXPECT_FALSE([dispatcher respondsToSelector:@selector(show)]); @@ -395,7 +398,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { // Tests that a registered MetricsRecorder is successfully // notified when commands with no arguments are invoked on the dispatcher. -TEST(CommandDispatcherTest, MetricsRecorderNoArguments) { +TEST_F(CommandDispatcherTest, MetricsRecorderNoArguments) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestSimpleTarget* target = [[CommandDispatcherTestSimpleTarget alloc] init]; @@ -418,7 +421,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { // Tests that a registered MetricsRecorder is successfully // notified when commands with arguments are invoked on the dispatcher. -TEST(CommandDispatcherTest, MetricsRecorderWithArguments) { +TEST_F(CommandDispatcherTest, MetricsRecorderWithArguments) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestTargetWithArguments* target = [[CommandDispatcherTestTargetWithArguments alloc] init]; @@ -460,7 +463,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { // Tests that the correct MetricsRecorders are notified for an invocation // when multiple recorders are registered. -TEST(CommandDispatcherTest, MetricsRecorderMultipleRecorders) { +TEST_F(CommandDispatcherTest, MetricsRecorderMultipleRecorders) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestSimpleTarget* showTarget = [[CommandDispatcherTestSimpleTarget alloc] init]; @@ -490,7 +493,7 @@ - (void)recordMetricForInvocation:(NSInvocation*)anInvocation { // Tests that if a selector registered to a MetricsRecorder is deregistered, // the MetricsRecorder is no longer notified when the selector is invoked on the // dispatcher. -TEST(CommandDispatcherTest, DeregisterMetricsRecorder) { +TEST_F(CommandDispatcherTest, DeregisterMetricsRecorder) { id dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcherTestSimpleTarget* target = [[CommandDispatcherTestSimpleTarget alloc] init]; diff --git a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_footer_item_unittest.mm b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_footer_item_unittest.mm index 8c1f95cea2887b..65c9fa76b27268 100644 --- a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_footer_item_unittest.mm +++ b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_footer_item_unittest.mm @@ -5,6 +5,7 @@ #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_footer_item.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #import "third_party/ocmock/gtest_support.h" @@ -14,8 +15,10 @@ namespace { +using ContentSuggestionsFooterItemTest = PlatformTest; + // Tests that configureCell: sets the title of the button and the action. -TEST(ContentSuggestionsFooterItemTest, CellIsConfigured) { +TEST_F(ContentSuggestionsFooterItemTest, CellIsConfigured) { // Setup. NSString* title = @"testTitle"; ContentSuggestionsFooterItem* item = @@ -40,7 +43,7 @@ // Tests that the item is the delegate for the cell, and when the cell button is // tapped, the callback is called. -TEST(ContentSuggestionsFooterItemTest, CellTapped) { +TEST_F(ContentSuggestionsFooterItemTest, CellTapped) { NSString* title = @"testTitle"; __block BOOL hasBeenCalled = NO; __block ContentSuggestionsFooterCell* blockCell = nil; diff --git a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_header_item_unittest.mm b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_header_item_unittest.mm index 166f3015efada7..69e8de8c67dc22 100644 --- a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_header_item_unittest.mm +++ b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_header_item_unittest.mm @@ -5,6 +5,7 @@ #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_header_item.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -12,7 +13,9 @@ namespace { -TEST(ContentSuggestionsHeaderItemTest, CellClass) { +using ContentSuggestionsHeaderItemTest = PlatformTest; + +TEST_F(ContentSuggestionsHeaderItemTest, CellClass) { // Setup. ContentSuggestionsHeaderItem* item = [[ContentSuggestionsHeaderItem alloc] initWithType:0]; @@ -24,7 +27,7 @@ EXPECT_EQ([ContentSuggestionsHeaderCell class], [cell class]); } -TEST(ContentSuggestionsHeaderItemTest, Configure) { +TEST_F(ContentSuggestionsHeaderItemTest, Configure) { // Setup. UIView* view = [[UIView alloc] init]; ContentSuggestionsHeaderItem* item = diff --git a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item_unittest.mm b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item_unittest.mm index dafd30dcd8dd77..31085c813eabe8 100644 --- a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item_unittest.mm +++ b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item_unittest.mm @@ -8,6 +8,7 @@ #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_cell.h" #include "ios/chrome/grit/ios_strings.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #import "third_party/ocmock/gtest_support.h" #include "ui/base/l10n/l10n_util.h" @@ -19,9 +20,11 @@ namespace { +using ContentSuggestionsItemTest = PlatformTest; + // Tests that configureCell: sets all the fields of the cell except the image // and fetches the image through the delegate. -TEST(ContentSuggestionsItemTest, CellIsConfiguredWithoutImage) { +TEST_F(ContentSuggestionsItemTest, CellIsConfiguredWithoutImage) { // Setup. NSString* title = @"testTitle"; GURL url = GURL("http://chromium.org"); @@ -60,7 +63,7 @@ // Tests that configureCell: does not call the delegate if it fetched the image // once. -TEST(ContentSuggestionsItemTest, DontFetchImageIfImageIsBeingFetched) { +TEST_F(ContentSuggestionsItemTest, DontFetchImageIfImageIsBeingFetched) { // Setup. NSString* title = @"testTitle"; GURL url = GURL("http://chromium.org"); @@ -96,7 +99,7 @@ // Tests that the delegate is not called when |hasImage| is set to NO. If the // delegate is called an exception is raised. -TEST(ContentSuggestionsItemTest, NoDelegateCallWhenHasNotImage) { +TEST_F(ContentSuggestionsItemTest, NoDelegateCallWhenHasNotImage) { // Setup. NSString* title = @"testTitle"; GURL url = GURL("http://chromium.org"); @@ -116,7 +119,7 @@ } // Tests that the display of the image is animated only for the first time. -TEST(ContentSuggestionsItemTest, ImageAnimatedOnlyTheFirstTime) { +TEST_F(ContentSuggestionsItemTest, ImageAnimatedOnlyTheFirstTime) { // Setup. NSString* title = @"testTitle"; GURL url = GURL("http://chromium.org"); @@ -143,7 +146,7 @@ } // Tests the custom actions when there is no read later actions. -TEST(ContentSuggestionsItemTest, NoReadLaterAction) { +TEST_F(ContentSuggestionsItemTest, NoReadLaterAction) { // Setup. NSString* title = @"testTitle"; GURL url = GURL("http://chromium.org"); diff --git a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_learn_more_item_unittest.mm b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_learn_more_item_unittest.mm index 92cc7a5532dd12..bc6f1dcb93d526 100644 --- a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_learn_more_item_unittest.mm +++ b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_learn_more_item_unittest.mm @@ -5,6 +5,7 @@ #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_learn_more_item.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #import "third_party/ocmock/gtest_support.h" @@ -14,7 +15,9 @@ namespace { -TEST(ContentSuggestionsLearnMoreItemTest, CellClass) { +using ContentSuggestionsLearnMoreItemTest = PlatformTest; + +TEST_F(ContentSuggestionsLearnMoreItemTest, CellClass) { // Setup. ContentSuggestionsLearnMoreItem* item = [[ContentSuggestionsLearnMoreItem alloc] initWithType:0]; @@ -26,7 +29,7 @@ EXPECT_EQ([ContentSuggestionsLearnMoreCell class], [cell class]); } -TEST(ContentSuggestionsLearnMoreItemTest, Configure) { +TEST_F(ContentSuggestionsLearnMoreItemTest, Configure) { // Setup. ContentSuggestionsLearnMoreItem* item = [[ContentSuggestionsLearnMoreItem alloc] initWithType:0]; diff --git a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item_unittest.mm b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item_unittest.mm index 0564dd3330a4fe..77bdf845f5d417 100644 --- a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item_unittest.mm +++ b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item_unittest.mm @@ -9,6 +9,7 @@ #import "ios/chrome/browser/ui/favicon/favicon_view.h" #include "ios/chrome/browser/ui/ui_util.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #import "third_party/ocmock/gtest_support.h" @@ -18,7 +19,9 @@ namespace { -TEST(ContentSuggestionsMostVisitedItemTest, CellClass) { +using ContentSuggestionsMostVisitedItemTest = PlatformTest; + +TEST_F(ContentSuggestionsMostVisitedItemTest, CellClass) { // Setup. ContentSuggestionsMostVisitedItem* item = [[ContentSuggestionsMostVisitedItem alloc] initWithType:0]; @@ -30,7 +33,7 @@ ASSERT_EQ([ContentSuggestionsMostVisitedCell class], [cell class]); } -TEST(ContentSuggestionsMostVisitedItemTest, Configure) { +TEST_F(ContentSuggestionsMostVisitedItemTest, Configure) { // Setup. NSString* title = @"Test title."; ContentSuggestionsMostVisitedItem* item = diff --git a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_whats_new_item_unittest.mm b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_whats_new_item_unittest.mm index 9ca5ab71f49366..9c897bf542b3d0 100644 --- a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_whats_new_item_unittest.mm +++ b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_whats_new_item_unittest.mm @@ -5,6 +5,7 @@ #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_whats_new_item.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #import "third_party/ocmock/gtest_support.h" @@ -14,7 +15,9 @@ namespace { -TEST(ContentSuggestionsWhatsNewItemTest, CellClass) { +using ContentSuggestionsWhatsNewItemTest = PlatformTest; + +TEST_F(ContentSuggestionsWhatsNewItemTest, CellClass) { // Setup. ContentSuggestionsWhatsNewItem* item = [[ContentSuggestionsWhatsNewItem alloc] initWithType:0]; @@ -26,7 +29,7 @@ EXPECT_EQ([ContentSuggestionsWhatsNewCell class], [cell class]); } -TEST(ContentSuggestionsWhatsNewItemTest, Configure) { +TEST_F(ContentSuggestionsWhatsNewItemTest, Configure) { // Setup. UIImage* image = [[UIImage alloc] init]; NSString* text = @"What's new test!"; diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater_unittest.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater_unittest.mm index 00fe81b495bdd5..273fd0c2c79a23 100644 --- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater_unittest.mm +++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater_unittest.mm @@ -22,7 +22,9 @@ namespace { -TEST(ContentSuggestionsCollectionUpdaterTest, addEmptyItemToEmptySection) { +using ContentSuggestionsCollectionUpdaterTest = PlatformTest; + +TEST_F(ContentSuggestionsCollectionUpdaterTest, addEmptyItemToEmptySection) { // Setup. NSString* emptyString = @"test empty"; id mockDataSource = OCMProtocolMock(@protocol(ContentSuggestionsDataSource)); @@ -59,8 +61,8 @@ EXPECT_EQ(emptyString, item.detailText); } -TEST(ContentSuggestionsCollectionUpdaterTest, - addEmptyItemToSectionWithoutText) { +TEST_F(ContentSuggestionsCollectionUpdaterTest, + addEmptyItemToSectionWithoutText) { // Setup. id mockDataSource = OCMProtocolMock(@protocol(ContentSuggestionsDataSource)); ContentSuggestionsCollectionUpdater* updater = @@ -92,7 +94,7 @@ ASSERT_EQ(0, [model numberOfItemsInSection:0]); } -TEST(ContentSuggestionsCollectionUpdaterTest, addEmptyItemToSection) { +TEST_F(ContentSuggestionsCollectionUpdaterTest, addEmptyItemToSection) { // Setup. id mockDataSource = OCMProtocolMock(@protocol(ContentSuggestionsDataSource)); ContentSuggestionsCollectionUpdater* updater = diff --git a/ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier_unittest.mm b/ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier_unittest.mm index c6c4148e92c3df..e86afefb3f5296 100644 --- a/ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier_unittest.mm +++ b/ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier_unittest.mm @@ -6,6 +6,7 @@ #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestions_section_information.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -17,8 +18,10 @@ @interface ContentSuggestionIdentifierSubclassTest : ContentSuggestionIdentifier @implementation ContentSuggestionIdentifierSubclassTest @end +using ContentSuggestionIdentifierTest = PlatformTest; + // Tests different equality scenario. -TEST(ContentSuggestionIdentifierTest, IsEquals) { +TEST_F(ContentSuggestionIdentifierTest, IsEquals) { // Setup. std::string id1("identifier"); std::string id2("identifier"); @@ -48,7 +51,7 @@ @implementation ContentSuggestionIdentifierSubclassTest } // Test non-equality between different objects. -TEST(ContentSuggestionIdentifierTest, IsNotEqualsDifferentObjects) { +TEST_F(ContentSuggestionIdentifierTest, IsNotEqualsDifferentObjects) { // Setup. NSObject* object = [[NSObject alloc] init]; ContentSuggestionIdentifier* suggestionIdentifier = @@ -59,7 +62,7 @@ @implementation ContentSuggestionIdentifierSubclassTest } // Test non-equality. -TEST(ContentSuggestionIdentifierTest, IsNotEquals) { +TEST_F(ContentSuggestionIdentifierTest, IsNotEquals) { // Setup. std::string id1("identifier"); std::string id2("identifier2"); diff --git a/ios/chrome/browser/ui/contextual_search/touch_to_search_permissions_mediator_unittest.mm b/ios/chrome/browser/ui/contextual_search/touch_to_search_permissions_mediator_unittest.mm index d1d3b5ce8cbd3e..2e4055d70286d9 100644 --- a/ios/chrome/browser/ui/contextual_search/touch_to_search_permissions_mediator_unittest.mm +++ b/ios/chrome/browser/ui/contextual_search/touch_to_search_permissions_mediator_unittest.mm @@ -526,7 +526,9 @@ ConnectionType GetCurrentConnectionType() const override { #pragma mark - Unit tests for availability class method. -TEST(TouchToSearchPermissionsAvailabilityTest, CommandLinePermissions) { +using TouchToSearchPermissionsAvailabilityTest = PlatformTest; + +TEST_F(TouchToSearchPermissionsAvailabilityTest, CommandLinePermissions) { const struct { bool set_disable; bool set_enable; @@ -555,7 +557,7 @@ ConnectionType GetCurrentConnectionType() const override { } } -TEST(TouchToSearchPermissionsAvailabilityTest, FieldTrial) { +TEST_F(TouchToSearchPermissionsAvailabilityTest, FieldTrial) { // Field trial support is not currently supported, so it is expected // that under all field trial configs, the feature will remain disabled. // If field trial support is added back in, this test should be updated. @@ -586,7 +588,9 @@ ConnectionType GetCurrentConnectionType() const override { #pragma mark - Unit tests for mock class -TEST(MockTouchToSearchPermissionsTest, Mocking) { +using MockTouchToSearchPermissionsTest = PlatformTest; + +TEST_F(MockTouchToSearchPermissionsTest, Mocking) { MockTouchToSearchPermissionsMediator* scoped_permissions = [[MockTouchToSearchPermissionsMediator alloc] initWithBrowserState:nullptr]; diff --git a/ios/chrome/browser/ui/dialogs/nsurl_protection_space_util_unittest.mm b/ios/chrome/browser/ui/dialogs/nsurl_protection_space_util_unittest.mm index 1502ebfded21f9..fd5f912c01990a 100644 --- a/ios/chrome/browser/ui/dialogs/nsurl_protection_space_util_unittest.mm +++ b/ios/chrome/browser/ui/dialogs/nsurl_protection_space_util_unittest.mm @@ -55,8 +55,10 @@ } // namespace +using NSURLProtectionSpaceUtilTest = PlatformTest; + // Tests that dialog can not be shown without valid host. -TEST(NSURLProtectionSpaceUtilTest, CantShowWithoutValidHost) { +TEST_F(NSURLProtectionSpaceUtilTest, CantShowWithoutValidHost) { NSURLProtectionSpace* protectionSpace = GetProtectionSpaceForHost(@"", NSURLProtectionSpaceHTTPS); @@ -64,7 +66,7 @@ } // Tests that dialog can not be shown with invalid port. -TEST(NSURLProtectionSpaceUtilTest, CantShowWithoutValidPort) { +TEST_F(NSURLProtectionSpaceUtilTest, CantShowWithoutValidPort) { NSURLProtectionSpace* protectionSpace = GetProtectionSpaceForHost(kTestHost, NSURLProtectionSpaceHTTPS, INT_MAX); @@ -72,7 +74,7 @@ } // Tests showing the dialog for SOCKS proxy server. -TEST(NSURLProtectionSpaceUtilTest, ShowForSocksProxy) { +TEST_F(NSURLProtectionSpaceUtilTest, ShowForSocksProxy) { NSURLProtectionSpace* protectionSpace = GetProtectionSpaceForProxyHost(kTestHost, NSURLProtectionSpaceSOCKSProxy); @@ -93,7 +95,7 @@ } // Tests showing the dialog for http proxy server. -TEST(NSURLProtectionSpaceUtilTest, ShowForHttpProxy) { +TEST_F(NSURLProtectionSpaceUtilTest, ShowForHttpProxy) { NSURLProtectionSpace* protectionSpace = GetProtectionSpaceForProxyHost(kTestHost, NSURLProtectionSpaceHTTPProxy); @@ -113,7 +115,7 @@ } // Tests showing the dialog for https proxy server. -TEST(NSURLProtectionSpaceUtilTest, ShowForHttpsProxy) { +TEST_F(NSURLProtectionSpaceUtilTest, ShowForHttpsProxy) { NSURLProtectionSpace* protectionSpace = GetProtectionSpaceForProxyHost(kTestHost, NSURLProtectionSpaceHTTPSProxy); @@ -144,7 +146,7 @@ } // Tests showing the dialog for http server. -TEST(NSURLProtectionSpaceUtilTest, ShowForHttpServer) { +TEST_F(NSURLProtectionSpaceUtilTest, ShowForHttpServer) { NSURLProtectionSpace* protectionSpace = GetProtectionSpaceForHost(kTestHost, NSURLProtectionSpaceHTTP); @@ -163,7 +165,7 @@ } // Tests showing the dialog for https server. -TEST(NSURLProtectionSpaceUtilTest, ShowForHttpsServer) { +TEST_F(NSURLProtectionSpaceUtilTest, ShowForHttpsServer) { NSURLProtectionSpace* protectionSpace = GetProtectionSpaceForHost(kTestHost, NSURLProtectionSpaceHTTPS); diff --git a/ios/chrome/browser/ui/elements/activity_overlay_coordinator_unittest.mm b/ios/chrome/browser/ui/elements/activity_overlay_coordinator_unittest.mm index 55d31d64bd171d..e5a772c19e9c9c 100644 --- a/ios/chrome/browser/ui/elements/activity_overlay_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/elements/activity_overlay_coordinator_unittest.mm @@ -8,14 +8,17 @@ #import "ios/chrome/browser/ui/elements/activity_overlay_view_controller.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using ActivityOverlayCoordinatorTest = PlatformTest; + // Tests that invoking start and stop on the coordinator presents and dismisses // the activity overlay view, respectively. -TEST(ActivityOverlayCoordinatorTest, StartAndStop) { +TEST_F(ActivityOverlayCoordinatorTest, StartAndStop) { __weak UIView* overlay_view; @autoreleasepool { UIViewController* base_view_controller = [[UIViewController alloc] init]; diff --git a/ios/chrome/browser/ui/elements/selector_coordinator_unittest.mm b/ios/chrome/browser/ui/elements/selector_coordinator_unittest.mm index 7ba092deadf334..a29310a470e98e 100644 --- a/ios/chrome/browser/ui/elements/selector_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/elements/selector_coordinator_unittest.mm @@ -9,6 +9,7 @@ #import "ios/chrome/browser/ui/elements/selector_view_controller_delegate.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "third_party/ocmock/OCMock/OCMock.h" #include "third_party/ocmock/gtest_support.h" @@ -22,9 +23,11 @@ @interface SelectorCoordinator () @property SelectorPickerViewController* selectorPickerViewController; @end +using SelectorCoordinatorTest = PlatformTest; + // Tests that invoking start on the coordinator presents the selector view, and // that invoking stop dismisses the view and invokes the delegate. -TEST(SelectorCoordinatorTest, StartAndStop) { +TEST_F(SelectorCoordinatorTest, StartAndStop) { UIWindow* keyWindow = [[UIApplication sharedApplication] keyWindow]; UIViewController* rootViewController = keyWindow.rootViewController; SelectorCoordinator* coordinator = [[SelectorCoordinator alloc] @@ -47,7 +50,7 @@ @interface SelectorCoordinator () // Tests that calling the view controller delegate method invokes the // SelectorCoordinatorDelegate method and stops the coordinator. -TEST(SelectorCoordinatorTest, Delegate) { +TEST_F(SelectorCoordinatorTest, Delegate) { UIWindow* keyWindow = [[UIApplication sharedApplication] keyWindow]; UIViewController* rootViewController = keyWindow.rootViewController; SelectorCoordinator* coordinator = [[SelectorCoordinator alloc] diff --git a/ios/chrome/browser/ui/elements/selector_picker_view_controller_unittest.mm b/ios/chrome/browser/ui/elements/selector_picker_view_controller_unittest.mm index e88d38f66c9231..579b2094cc23f9 100644 --- a/ios/chrome/browser/ui/elements/selector_picker_view_controller_unittest.mm +++ b/ios/chrome/browser/ui/elements/selector_picker_view_controller_unittest.mm @@ -8,6 +8,7 @@ #import "ios/chrome/browser/ui/elements/selector_view_controller_delegate.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "third_party/ocmock/OCMock/OCMock.h" #include "third_party/ocmock/gtest_support.h" @@ -22,9 +23,11 @@ @interface SelectorPickerViewController () @property(nonatomic, retain) UIPickerView* pickerView; @end +using SelectorPickerViewControllerTest = PlatformTest; + // Test that invoking the right bar button action ("Done") invokes the delegate // callback with the appropriate selected item. -TEST(SelectorPickerViewControllerTest, Done) { +TEST_F(SelectorPickerViewControllerTest, Done) { NSString* option1 = @"Option 1"; NSString* option2 = @"Option 2"; NSOrderedSet* options = @@ -56,7 +59,7 @@ @interface SelectorPickerViewController () // Test that invoking the right bar button action ("Cancel") invokes the // delegate callback with the default item. -TEST(SelectorPickerViewControllerTest, Cancel) { +TEST_F(SelectorPickerViewControllerTest, Cancel) { NSString* option1 = @"Option 1"; NSString* option2 = @"Option 2"; NSOrderedSet* options = @@ -87,7 +90,7 @@ @interface SelectorPickerViewController () // Test that the picker view is styled appropriately based on parameters // provided at initialization. -TEST(SelectorPickerViewControllerTest, DefaultStyling) { +TEST_F(SelectorPickerViewControllerTest, DefaultStyling) { NSString* option1 = @"Option 1"; NSString* option2 = @"Option 2"; NSString* option3 = @"Option 3"; diff --git a/ios/chrome/browser/ui/first_run/first_run_util_unittest.mm b/ios/chrome/browser/ui/first_run/first_run_util_unittest.mm index 50c78201bb1db6..ed8fb02a84aeb6 100644 --- a/ios/chrome/browser/ui/first_run/first_run_util_unittest.mm +++ b/ios/chrome/browser/ui/first_run/first_run_util_unittest.mm @@ -6,6 +6,7 @@ #include "ios/chrome/browser/ui/first_run/first_run_util.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,7 +14,9 @@ namespace { -TEST(UICommonTest, TestFixOrphanWord) { +using UICommonTest = PlatformTest; + +TEST_F(UICommonTest, TestFixOrphanWord) { NSString* englishString = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tempus" " dignissim congue. Morbi pulvinar vitae purus at mollis. Sed laoreet " diff --git a/ios/chrome/browser/ui/history/history_entries_status_item_unittest.mm b/ios/chrome/browser/ui/history/history_entries_status_item_unittest.mm index 26b93d51acad35..d72a38dc8b2085 100644 --- a/ios/chrome/browser/ui/history/history_entries_status_item_unittest.mm +++ b/ios/chrome/browser/ui/history/history_entries_status_item_unittest.mm @@ -13,6 +13,7 @@ #include "ios/chrome/grit/ios_strings.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "third_party/ocmock/OCMock/OCMock.h" #include "third_party/ocmock/gtest_support.h" #include "ui/base/l10n/l10n_util.h" @@ -46,10 +47,12 @@ - (void)historyEntriesStatusItem:(HistoryEntriesStatusItem*)item namespace { +using HistoryEntriesStatusItemTest = PlatformTest; + // Tests that configuring a cell for HistoryEntriesStatusItem with hidden // property set to YES results in an empty label, regardless of what // showsOtherBrowsingDataNotice is set to. -TEST(HistoryEntriesStatusItemTest, TestHidden) { +TEST_F(HistoryEntriesStatusItemTest, TestHidden) { HistoryEntriesStatusItem* item = [[HistoryEntriesStatusItem alloc] initWithType:0]; item.hidden = YES; @@ -62,7 +65,7 @@ - (void)historyEntriesStatusItem:(HistoryEntriesStatusItem*)item // Tests that configuring a cell for HistoryEntriesStatusItem with // showsOtherBrowsingDataNotice set to YES adds other browsing // data text to the label, while set to NO has no text. -TEST(HistoryEntriesStatusItemTest, TestOtherBrowsingDataNotice) { +TEST_F(HistoryEntriesStatusItemTest, TestOtherBrowsingDataNotice) { HistoryEntriesStatusItem* item = [[HistoryEntriesStatusItem alloc] initWithType:0]; HistoryEntriesStatusCell* cell = [[HistoryEntriesStatusCell alloc] init]; @@ -82,7 +85,7 @@ - (void)historyEntriesStatusItem:(HistoryEntriesStatusItem*)item // Tests that tapping on links on a configured cell invokes // the HistoryEntriesStatusItemDelegate method. -TEST(HistoryEntriesStatusItemTest, TestDelegate) { +TEST_F(HistoryEntriesStatusItemTest, TestDelegate) { HistoryEntriesStatusItem* item = [[HistoryEntriesStatusItem alloc] initWithType:0]; HistoryEntriesStatusCell* cell = [[HistoryEntriesStatusCell alloc] init]; diff --git a/ios/chrome/browser/ui/history/history_entry_item_unittest.mm b/ios/chrome/browser/ui/history/history_entry_item_unittest.mm index eacffdf15cfdc8..1d2c0529b969c4 100644 --- a/ios/chrome/browser/ui/history/history_entry_item_unittest.mm +++ b/ios/chrome/browser/ui/history/history_entry_item_unittest.mm @@ -11,6 +11,7 @@ #include "components/history/core/browser/browsing_history_service.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -37,10 +38,12 @@ return item; } +using HistoryEntryItemTest = PlatformTest; + // Tests that -[HistoryEntryItem configureCell:] sets the cell's textLabel text // to the item title, the detailTextLabel text to the URL, and the timeLabel // text to the timestamp. -TEST(HistoryEntryItemTest, ConfigureCell) { +TEST_F(HistoryEntryItemTest, ConfigureCell) { base::Time timestamp = base::Time::Now(); HistoryEntryItem* item = GetHistoryEntryItem(GURL(kTestUrl), kTestTitle, timestamp); @@ -56,7 +59,7 @@ // Tests that -[HistoryItem isEqualToHistoryItem:] returns YES if the two items // have the same URL and timestamp, and NO otherwise. -TEST(HistoryEntryItemTest, IsEqual) { +TEST_F(HistoryEntryItemTest, IsEqual) { base::Time timestamp = base::Time::Now(); base::Time timestamp2 = timestamp - base::TimeDelta::FromMinutes(1); HistoryEntryItem* history_entry = diff --git a/ios/chrome/browser/ui/icons/chrome_icon_unittest.mm b/ios/chrome/browser/ui/icons/chrome_icon_unittest.mm index 8ea5bc98f5f394..e9e97df81aceca 100644 --- a/ios/chrome/browser/ui/icons/chrome_icon_unittest.mm +++ b/ios/chrome/browser/ui/icons/chrome_icon_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #import "third_party/ocmock/ocmock_extensions.h" #include "ui/base/l10n/l10n_util_mac.h" @@ -20,14 +21,16 @@ - (void)doSomething; namespace { -TEST(ChromeIconTest, NonNilIcons) { +using ChromeIconTest = PlatformTest; + +TEST_F(ChromeIconTest, NonNilIcons) { EXPECT_TRUE([ChromeIcon backIcon]); EXPECT_TRUE([ChromeIcon closeIcon]); EXPECT_TRUE([ChromeIcon infoIcon]); EXPECT_TRUE([ChromeIcon searchIcon]); } -TEST(ChromeIconTest, Accessibility) { +TEST_F(ChromeIconTest, Accessibility) { EXPECT_TRUE([ChromeIcon backIcon].accessibilityIdentifier); EXPECT_TRUE([ChromeIcon backIcon].accessibilityLabel); @@ -41,12 +44,12 @@ - (void)doSomething; EXPECT_TRUE([ChromeIcon searchIcon].accessibilityLabel); } -TEST(ChromeIcontTest, RTL) { +TEST_F(ChromeIconTest, RTL) { EXPECT_TRUE([ChromeIcon backIcon].flipsForRightToLeftLayoutDirection); EXPECT_FALSE([ChromeIcon searchIcon].flipsForRightToLeftLayoutDirection); } -TEST(ChromeIconTest, TemplateBarButtonItem) { +TEST_F(ChromeIconTest, TemplateBarButtonItem) { UIImage* image = [UIImage imageNamed:@"ic_close"]; image.accessibilityIdentifier = @"identifier"; image.accessibilityLabel = @"label"; diff --git a/ios/chrome/browser/ui/key_commands_provider_unittest.mm b/ios/chrome/browser/ui/key_commands_provider_unittest.mm index 7d0d0a22026d27..240aa6637a7da8 100644 --- a/ios/chrome/browser/ui/key_commands_provider_unittest.mm +++ b/ios/chrome/browser/ui/key_commands_provider_unittest.mm @@ -18,7 +18,9 @@ typedef PlatformTest KeyCommandsProviderTest; -TEST(KeyCommandsProviderTest, NoTabs_EditingText_ReturnsObjects) { +using KeyCommandsProviderTest = PlatformTest; + +TEST_F(KeyCommandsProviderTest, NoTabs_EditingText_ReturnsObjects) { KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init]; id mockConsumer = [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)]; @@ -30,7 +32,7 @@ editingText:YES]); } -TEST(KeyCommandsProviderTest, ReturnsKeyCommandsObjects) { +TEST_F(KeyCommandsProviderTest, ReturnsKeyCommandsObjects) { KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init]; id mockConsumer = [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)]; @@ -45,7 +47,7 @@ } } -TEST(KeyCommandsProviderTest, MoreKeyboardCommandsWhenTabs) { +TEST_F(KeyCommandsProviderTest, MoreKeyboardCommandsWhenTabs) { KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init]; id mockConsumer = [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)]; @@ -68,7 +70,7 @@ EXPECT_GT(numberOfKeyCommandsWithTabs, numberOfKeyCommandsWithoutTabs); } -TEST(KeyCommandsProviderTest, LessKeyCommandsWhenTabsAndEditingText) { +TEST_F(KeyCommandsProviderTest, LessKeyCommandsWhenTabsAndEditingText) { KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init]; id mockConsumer = [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)]; diff --git a/ios/chrome/browser/ui/keyboard/UIKeyCommand+ChromeTest.mm b/ios/chrome/browser/ui/keyboard/UIKeyCommand+ChromeTest.mm index 311e425c7d88e4..3aa9a28f38bef2 100644 --- a/ios/chrome/browser/ui/keyboard/UIKeyCommand+ChromeTest.mm +++ b/ios/chrome/browser/ui/keyboard/UIKeyCommand+ChromeTest.mm @@ -6,6 +6,7 @@ #include "base/mac/scoped_nsobject.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,9 +14,11 @@ namespace { +using UIKeyCommandChromeTest = PlatformTest; + // Tests that UIApplication correctly calls the keyboard command action block // when invoked. -TEST(UIKeyCommandChromeTest, UIApplicationHandleKeyCommand_CallsBlock) { +TEST_F(UIKeyCommandChromeTest, UIApplicationHandleKeyCommand_CallsBlock) { __block BOOL called = NO; UIKeyCommand* command = [UIKeyCommand cr_keyCommandWithInput:@"" diff --git a/ios/chrome/browser/ui/main/main_coordinator_unittest.mm b/ios/chrome/browser/ui/main/main_coordinator_unittest.mm index e7fa0faa689233..c48ad690e66ef9 100644 --- a/ios/chrome/browser/ui/main/main_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/main/main_coordinator_unittest.mm @@ -8,12 +8,15 @@ #include "ios/chrome/browser/ui/main/main_view_controller.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif -TEST(MainCoordinatorTest, SizeViewController) { +using MainCoordinatorTest = PlatformTest; + +TEST_F(MainCoordinatorTest, SizeViewController) { CGRect rect = [UIScreen mainScreen].bounds; UIWindow* window = [UIApplication sharedApplication].keyWindow; MainCoordinator* coordinator = diff --git a/ios/chrome/browser/ui/native_content_controller_unittest.mm b/ios/chrome/browser/ui/native_content_controller_unittest.mm index e581f25ace84d1..ff75e3c319bb6d 100644 --- a/ios/chrome/browser/ui/native_content_controller_unittest.mm +++ b/ios/chrome/browser/ui/native_content_controller_unittest.mm @@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/logging.h" #import "ios/chrome/browser/ui/native_content_controller.h" +#include "base/logging.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -13,7 +14,9 @@ namespace { -TEST(NativeContentControllerTest, TestInitWithURL) { +using NativeContentControllerTest = PlatformTest; + +TEST_F(NativeContentControllerTest, TestInitWithURL) { GURL url("http://foo.bar.com"); NativeContentController* controller = [[NativeContentController alloc] initWithURL:url]; @@ -23,7 +26,7 @@ EXPECT_EQ(nil, controller.view); } -TEST(NativeContentControllerTest, TestInitWithEmptyNibNameAndURL) { +TEST_F(NativeContentControllerTest, TestInitWithEmptyNibNameAndURL) { GURL url("http://foo.bar.com"); NativeContentController* controller = [[NativeContentController alloc] initWithNibName:nil url:url]; @@ -33,7 +36,7 @@ EXPECT_EQ(nil, controller.view); } -TEST(NativeContentControllerTest, TestInitWithNibAndURL) { +TEST_F(NativeContentControllerTest, TestInitWithNibAndURL) { GURL url("http://foo.bar.com"); NSString* nibName = @"native_content_controller_test"; NativeContentController* controller = diff --git a/ios/chrome/browser/ui/page_not_available_controller_unittest.mm b/ios/chrome/browser/ui/page_not_available_controller_unittest.mm index 6c221366296d31..a699a9592f4b6b 100644 --- a/ios/chrome/browser/ui/page_not_available_controller_unittest.mm +++ b/ios/chrome/browser/ui/page_not_available_controller_unittest.mm @@ -2,17 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include -#include "base/logging.h" #import "ios/chrome/browser/ui/page_not_available_controller.h" +#include "base/logging.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" + #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif namespace { -TEST(PageNotAvailableControllerTest, TestInitWithURL) { +using PageNotAvailableControllerTest = PlatformTest; + +TEST_F(PageNotAvailableControllerTest, TestInitWithURL) { GURL url = GURL("http://foo.bar.com"); PageNotAvailableController* controller = [[PageNotAvailableController alloc] initWithUrl:url]; diff --git a/ios/chrome/browser/ui/payments/cells/accepted_payment_methods_item_unittest.mm b/ios/chrome/browser/ui/payments/cells/accepted_payment_methods_item_unittest.mm index 0d736ce554dfea..5f2d3199b751e4 100644 --- a/ios/chrome/browser/ui/payments/cells/accepted_payment_methods_item_unittest.mm +++ b/ios/chrome/browser/ui/payments/cells/accepted_payment_methods_item_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,9 +15,11 @@ namespace { +using PaymentRequestAcceptedPaymentMethodsItemTest = PlatformTest; + // Tests that the label and the images are set properly after a call to // |configureCell:|. -TEST(PaymentRequestAcceptedPaymentMethodsItemTest, TextLabelsAndImages) { +TEST_F(PaymentRequestAcceptedPaymentMethodsItemTest, TextLabelsAndImages) { AcceptedPaymentMethodsItem* item = [[AcceptedPaymentMethodsItem alloc] init]; NSString* message = @"Lorem ipsum dolor sit amet"; diff --git a/ios/chrome/browser/ui/payments/cells/autofill_profile_item_unittest.mm b/ios/chrome/browser/ui/payments/cells/autofill_profile_item_unittest.mm index 207cfa9fcf64eb..18f71bd7d7784a 100644 --- a/ios/chrome/browser/ui/payments/cells/autofill_profile_item_unittest.mm +++ b/ios/chrome/browser/ui/payments/cells/autofill_profile_item_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,8 +15,10 @@ namespace { +using PaymentRequestAutofillProfileItemTest = PlatformTest; + // Tests that the labels are set properly after a call to |configureCell:|. -TEST(PaymentRequestAutofillProfileItemTest, TextLabels) { +TEST_F(PaymentRequestAutofillProfileItemTest, TextLabels) { AutofillProfileItem* item = [[AutofillProfileItem alloc] init]; NSString* name = @"Jon Doe"; diff --git a/ios/chrome/browser/ui/payments/cells/page_info_item_unittest.mm b/ios/chrome/browser/ui/payments/cells/page_info_item_unittest.mm index cf8e1d5420a527..b82cb6fc38fc45 100644 --- a/ios/chrome/browser/ui/payments/cells/page_info_item_unittest.mm +++ b/ios/chrome/browser/ui/payments/cells/page_info_item_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,9 +15,11 @@ namespace { +using PaymentRequestPageInfoItemTest = PlatformTest; + // Tests that the labels and image are set properly after a call to // |configureCell:|. -TEST(PaymentRequestPageInfoItemTest, TextLabels) { +TEST_F(PaymentRequestPageInfoItemTest, TextLabels) { PageInfoItem* item = [[PageInfoItem alloc] init]; UIImage* pageFavicon = CollectionViewTestImage(); diff --git a/ios/chrome/browser/ui/payments/cells/payment_method_item_unittest.mm b/ios/chrome/browser/ui/payments/cells/payment_method_item_unittest.mm index d3895f2972547b..91be9db0cb6eb0 100644 --- a/ios/chrome/browser/ui/payments/cells/payment_method_item_unittest.mm +++ b/ios/chrome/browser/ui/payments/cells/payment_method_item_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,9 +15,11 @@ namespace { +using PaymentRequestPaymentMethodItemTest = PlatformTest; + // Tests that the labels and image are set properly after a call to // |configureCell:|. -TEST(PaymentRequestPaymentMethodItemTest, TextLabels) { +TEST_F(PaymentRequestPaymentMethodItemTest, TextLabels) { PaymentMethodItem* item = [[PaymentMethodItem alloc] init]; NSString* methodID = @"BobPay - ****-6789"; diff --git a/ios/chrome/browser/ui/payments/cells/payments_selector_edit_item_unittests.mm b/ios/chrome/browser/ui/payments/cells/payments_selector_edit_item_unittests.mm index de11de45d9fdfe..9bf5828a7e7757 100644 --- a/ios/chrome/browser/ui/payments/cells/payments_selector_edit_item_unittests.mm +++ b/ios/chrome/browser/ui/payments/cells/payments_selector_edit_item_unittests.mm @@ -8,6 +8,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -15,8 +16,10 @@ namespace { +using PaymentRequestPaymentsSelectorEditItemTest = PlatformTest; + // Tests that the UILabels are set properly after a call to |configureCell:|. -TEST(PaymentRequestPaymentsSelectorEditItemTest, TextLabels) { +TEST_F(PaymentRequestPaymentsSelectorEditItemTest, TextLabels) { PaymentsSelectorEditItem* item = [[PaymentsSelectorEditItem alloc] init]; NSString* name = @"Name text"; NSString* value = @"Value text"; diff --git a/ios/chrome/browser/ui/payments/cells/payments_text_item_unittest.mm b/ios/chrome/browser/ui/payments/cells/payments_text_item_unittest.mm index 9a217005a5ad39..2930b77880a8be 100644 --- a/ios/chrome/browser/ui/payments/cells/payments_text_item_unittest.mm +++ b/ios/chrome/browser/ui/payments/cells/payments_text_item_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,9 +15,11 @@ namespace { +using PaymentRequestPaymentsTextItemTest = PlatformTest; + // Tests that the text label and the image are set properly after a call to // |configureCell:|. -TEST(PaymentRequestPaymentsTextItemTest, TextLabelAndImage) { +TEST_F(PaymentRequestPaymentsTextItemTest, TextLabelAndImage) { PaymentsTextItem* item = [[PaymentsTextItem alloc] init]; NSString* text = @"Lorem ipsum"; diff --git a/ios/chrome/browser/ui/payments/cells/price_item_unittest.mm b/ios/chrome/browser/ui/payments/cells/price_item_unittest.mm index abb71ef7df818b..4e442fe47a229c 100644 --- a/ios/chrome/browser/ui/payments/cells/price_item_unittest.mm +++ b/ios/chrome/browser/ui/payments/cells/price_item_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,8 +15,10 @@ namespace { +using PaymentRequestPriceItemTest = PlatformTest; + // Tests that the labels are set properly after a call to |configureCell:|. -TEST(PaymentRequestPriceItemTest, TextLabels) { +TEST_F(PaymentRequestPriceItemTest, TextLabels) { PriceItem* priceItem = [[PriceItem alloc] init]; NSString* item = @"Total"; @@ -41,7 +44,7 @@ } // Tests that the labels are provided with the correct amount of space. -TEST(PaymentRequestPriceItemTest, TextLabelTargetWidths) { +TEST_F(PaymentRequestPriceItemTest, TextLabelTargetWidths) { // Make the cell 164 wide so that after allocating 4 * kHorizontalPadding (16) // space for the margins and area between the labels, there is 100 available. // Accordingly, in each of the cases below where the sum of the desired label diff --git a/ios/chrome/browser/ui/payments/country_selection_coordinator_unittest.mm b/ios/chrome/browser/ui/payments/country_selection_coordinator_unittest.mm index cf93bf8b0c9ef8..8e956eaeaa21af 100644 --- a/ios/chrome/browser/ui/payments/country_selection_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/payments/country_selection_coordinator_unittest.mm @@ -14,7 +14,7 @@ #error "This file requires ARC support." #endif -class PaymentRequestCountrySelectionCoordinatorTest : public PlatformTest {}; +using PaymentRequestCountrySelectionCoordinatorTest = PlatformTest; // Tests that invoking start and stop on the coordinator presents and dismisses // the payment request picker view controller, respectively. diff --git a/ios/chrome/browser/ui/payments/payment_request_error_coordinator_unittest.mm b/ios/chrome/browser/ui/payments/payment_request_error_coordinator_unittest.mm index b7fbc3204f5e1e..3551b081db3e93 100644 --- a/ios/chrome/browser/ui/payments/payment_request_error_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/payments/payment_request_error_coordinator_unittest.mm @@ -18,7 +18,7 @@ #error "This file requires ARC support." #endif -class PaymentRequestErrorCoordinatorTest : public PlatformTest {}; +using PaymentRequestErrorCoordinatorTest = PlatformTest; // Tests that invoking start and stop on the coordinator presents and dismisses // the payment request error view controller, respectively. diff --git a/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller_unittest.mm b/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller_unittest.mm index a189132316f8f3..f730a9027478b7 100644 --- a/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller_unittest.mm +++ b/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller_unittest.mm @@ -37,7 +37,7 @@ #pragma mark - ReadingListCollectionViewControllerTest -class ReadingListCollectionViewControllerTest : public testing::Test { +class ReadingListCollectionViewControllerTest : public PlatformTest { public: ReadingListCollectionViewControllerTest() {} ~ReadingListCollectionViewControllerTest() override {} @@ -51,7 +51,7 @@ id mock_delegate_; void SetUp() override { - testing::Test::SetUp(); + PlatformTest::SetUp(); EXPECT_CALL(mock_favicon_service_, GetLargestRawFaviconForPageURL(_, _, _, _, _)) diff --git a/ios/chrome/browser/ui/reading_list/text_badge_view_unittest.mm b/ios/chrome/browser/ui/reading_list/text_badge_view_unittest.mm index f1dc3db2b7be6e..7f74de9d70fe35 100644 --- a/ios/chrome/browser/ui/reading_list/text_badge_view_unittest.mm +++ b/ios/chrome/browser/ui/reading_list/text_badge_view_unittest.mm @@ -6,26 +6,29 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using TextBadgeViewTest = PlatformTest; + // Test that the |text| property is set during initialization. -TEST(TextBadgeViewTest, CreateBadge) { +TEST_F(TextBadgeViewTest, CreateBadge) { TextBadgeView* badge = [[TextBadgeView alloc] initWithText:@"text"]; EXPECT_NSEQ(@"text", badge.text); } // Test setting the |text| property. -TEST(TextBadgeViewTest, SetText) { +TEST_F(TextBadgeViewTest, SetText) { TextBadgeView* badge = [[TextBadgeView alloc] initWithText:@"text 1"]; [badge setText:@"text 2"]; EXPECT_NSEQ(@"text 2", badge.text); } // Test that the accessibility label matches the display text. -TEST(TextBadgeViewTest, Accessibility) { +TEST_F(TextBadgeViewTest, Accessibility) { TextBadgeView* badge = [[TextBadgeView alloc] initWithText:@"display"]; UIView* superview = [[UIView alloc] initWithFrame:CGRectZero]; [superview addSubview:badge]; diff --git a/ios/chrome/browser/ui/safe_mode/safe_mode_coordinator_unittest.mm b/ios/chrome/browser/ui/safe_mode/safe_mode_coordinator_unittest.mm index f8e91c3635fd21..852136228cca9f 100644 --- a/ios/chrome/browser/ui/safe_mode/safe_mode_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/safe_mode/safe_mode_coordinator_unittest.mm @@ -8,12 +8,15 @@ #include "base/mac/scoped_nsobject.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif -TEST(SafeModeCoordinatorTest, RootVC) { +using SafeModeCoordinatorTest = PlatformTest; + +TEST_F(SafeModeCoordinatorTest, RootVC) { // Expect that starting a safe mode coordinator will populate the root view // controller. base::scoped_nsobject window( diff --git a/ios/chrome/browser/ui/settings/cells/account_signin_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/account_signin_item_unittest.mm index 9096997bb9f51e..22905fdc77b9dc 100644 --- a/ios/chrome/browser/ui/settings/cells/account_signin_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/account_signin_item_unittest.mm @@ -9,6 +9,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -17,7 +18,9 @@ // Tests that the UIImage and UILabels are set properly after a call to // |configureCell:|. -TEST(AccountSignInItemTest, ImageView) { +using AccountSignInItemTest = PlatformTest; + +TEST_F(AccountSignInItemTest, ImageView) { AccountSignInItem* item = [[AccountSignInItem alloc] initWithType:0]; UIImage* image = [[UIImage alloc] init]; diff --git a/ios/chrome/browser/ui/settings/cells/autofill_data_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/autofill_data_item_unittest.mm index 3dbe6cc7bf446c..13e94e9d8691b9 100644 --- a/ios/chrome/browser/ui/settings/cells/autofill_data_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/autofill_data_item_unittest.mm @@ -7,13 +7,16 @@ #import "ios/third_party/material_components_ios/src/components/CollectionCells/src/MaterialCollectionCells.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using AutofillDataItemTest = PlatformTest; + // Tests that the UILabels are set properly after a call to |configureCell:|. -TEST(AutofillDataItemTest, TextLabels) { +TEST_F(AutofillDataItemTest, TextLabels) { AutofillDataItem* item = [[AutofillDataItem alloc] initWithType:0]; NSString* mainText = @"Main text"; NSString* leadingDetailText = @"Leading detail text"; diff --git a/ios/chrome/browser/ui/settings/cells/byo_textfield_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/byo_textfield_item_unittest.mm index df3ebd2b5128e3..ea858f9f481c01 100644 --- a/ios/chrome/browser/ui/settings/cells/byo_textfield_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/byo_textfield_item_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,8 +14,10 @@ namespace { +using BYOTextFieldItemTest = PlatformTest; + // Tests that the textfield is set properly after a call to |configureCell:|. -TEST(BYOTextFieldItemTest, ConfigureCell) { +TEST_F(BYOTextFieldItemTest, ConfigureCell) { BYOTextFieldItem* item = [[BYOTextFieldItem alloc] initWithType:0]; BYOTextFieldCell* cell = [[[item cellClass] alloc] init]; EXPECT_TRUE([cell isMemberOfClass:[BYOTextFieldCell class]]); diff --git a/ios/chrome/browser/ui/settings/cells/card_multiline_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/card_multiline_item_unittest.mm index 6c08662e664ddd..9cef450b0078d2 100644 --- a/ios/chrome/browser/ui/settings/cells/card_multiline_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/card_multiline_item_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,8 +14,10 @@ namespace { +using CardMultilineItemTest = PlatformTest; + // Tests that the text is honoured after a call to |configureCell:|. -TEST(CardMultilineItemTest, ConfigureCell) { +TEST_F(CardMultilineItemTest, ConfigureCell) { CardMultilineItem* item = [[CardMultilineItem alloc] initWithType:0]; NSString* text = @"Test Disclaimer"; @@ -32,7 +35,7 @@ // Tests that the text label of an CardMultilineCell spans multiple // lines. -TEST(CardMultilineItemTest, MultipleLines) { +TEST_F(CardMultilineItemTest, MultipleLines) { CardMultilineCell* cell = [[CardMultilineCell alloc] init]; EXPECT_EQ(0, cell.textLabel.numberOfLines); } diff --git a/ios/chrome/browser/ui/settings/cells/copied_to_chrome_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/copied_to_chrome_item_unittest.mm index f8531a8ef25e89..c95451c781e2a4 100644 --- a/ios/chrome/browser/ui/settings/cells/copied_to_chrome_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/copied_to_chrome_item_unittest.mm @@ -9,6 +9,7 @@ #import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "ui/base/l10n/l10n_util_mac.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -17,8 +18,10 @@ namespace { +using CopiedToChromeItemTest = PlatformTest; + // Tests that the cell created out of a CopiedToChromeItem is set up properly. -TEST(CopiedToChromeItemTest, InitializeCell) { +TEST_F(CopiedToChromeItemTest, InitializeCell) { CopiedToChromeItem* item = [[CopiedToChromeItem alloc] initWithType:0]; id cell = [[[item cellClass] alloc] init]; diff --git a/ios/chrome/browser/ui/settings/cells/encryption_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/encryption_item_unittest.mm index 9fb0afb9a2bac2..11d05d1c3ea27c 100644 --- a/ios/chrome/browser/ui/settings/cells/encryption_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/encryption_item_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,9 +14,11 @@ namespace { +using EncryptionItemTest = PlatformTest; + // Tests that the text label, enabled status and accessory type are set properly // after a call to |configureCell:|. -TEST(EncryptionItemTest, ConfigureCell) { +TEST_F(EncryptionItemTest, ConfigureCell) { EncryptionItem* item = [[EncryptionItem alloc] initWithType:0]; EncryptionCell* cell = [[[item cellClass] alloc] init]; EXPECT_TRUE([cell isMemberOfClass:[EncryptionCell class]]); diff --git a/ios/chrome/browser/ui/settings/cells/import_data_multiline_detail_cell_unittest.mm b/ios/chrome/browser/ui/settings/cells/import_data_multiline_detail_cell_unittest.mm index 7f633f3b5a31d3..a33902f28ad8a4 100644 --- a/ios/chrome/browser/ui/settings/cells/import_data_multiline_detail_cell_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/import_data_multiline_detail_cell_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,9 +15,11 @@ namespace { +using ImportDataMultilineDetailItemTest = PlatformTest; + // Tests that the text and detail text are honoured after a call to // |configureCell:|. -TEST(ImportDataMultilineDetailItemTest, ConfigureCell) { +TEST_F(ImportDataMultilineDetailItemTest, ConfigureCell) { CollectionViewDetailItem* item = [[CollectionViewDetailItem alloc] initWithType:0]; item.cellClass = [ImportDataMultilineDetailCell class]; @@ -43,7 +46,7 @@ // Tests that the text label of an ImportDataMultilineDetailCell only has one // line but the detail text label spans multiple lines. -TEST(ImportDataMultilineDetailItemTest, MultipleLines) { +TEST_F(ImportDataMultilineDetailItemTest, MultipleLines) { ImportDataMultilineDetailCell* cell = [[ImportDataMultilineDetailCell alloc] init]; EXPECT_EQ(1, cell.textLabel.numberOfLines); diff --git a/ios/chrome/browser/ui/settings/cells/passphrase_error_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/passphrase_error_item_unittest.mm index 932a1e05969767..0fda301b1c5cff 100644 --- a/ios/chrome/browser/ui/settings/cells/passphrase_error_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/passphrase_error_item_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,8 +14,10 @@ namespace { +using PasswordDetailsItemTest = PlatformTest; + // Tests that the text label is set properly after a call to |configureCell:|. -TEST(PasswordDetailsItemTest, ConfigureCell) { +TEST_F(PasswordDetailsItemTest, ConfigureCell) { PassphraseErrorItem* item = [[PassphraseErrorItem alloc] initWithType:0]; PassphraseErrorCell* cell = [[[item cellClass] alloc] init]; EXPECT_TRUE([cell isMemberOfClass:[PassphraseErrorCell class]]); diff --git a/ios/chrome/browser/ui/settings/cells/password_details_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/password_details_item_unittest.mm index f3ef3a7dbb83bc..a5f7b21984461b 100644 --- a/ios/chrome/browser/ui/settings/cells/password_details_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/password_details_item_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,9 +14,11 @@ namespace { +using PasswordDetailsItemTest = PlatformTest; + // Tests that the text label and showing status are set properly after a call to // |configureCell:|. -TEST(PasswordDetailsItemTest, ConfigureCell) { +TEST_F(PasswordDetailsItemTest, ConfigureCell) { PasswordDetailsItem* item = [[PasswordDetailsItem alloc] initWithType:0]; PasswordDetailsCell* cell = [[[item cellClass] alloc] init]; EXPECT_TRUE([cell isMemberOfClass:[PasswordDetailsCell class]]); diff --git a/ios/chrome/browser/ui/settings/cells/sync_switch_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/sync_switch_item_unittest.mm index e76ff6217740a1..ec5b2b2fde5487 100644 --- a/ios/chrome/browser/ui/settings/cells/sync_switch_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/sync_switch_item_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,9 +14,11 @@ namespace { +using SyncSwitchItemTest = PlatformTest; + // Tests that the text label and showing status are set properly after a call to // |configureCell:|. -TEST(SyncSwitchItemTest, ConfigureCell) { +TEST_F(SyncSwitchItemTest, ConfigureCell) { SyncSwitchItem* item = [[SyncSwitchItem alloc] initWithType:0]; SyncSwitchCell* cell = [[[item cellClass] alloc] init]; EXPECT_TRUE([cell isMemberOfClass:[SyncSwitchCell class]]); @@ -42,7 +45,7 @@ // Tests that the text color and enabled state of the switch are set correctly // by a call to |configureCell:|. -TEST(SyncSwitchItemTest, EnabledAndDisabled) { +TEST_F(SyncSwitchItemTest, EnabledAndDisabled) { SyncSwitchCell* cell = [[SyncSwitchCell alloc] init]; SyncSwitchItem* item = [[SyncSwitchItem alloc] initWithType:0]; item.text = @"Test Switch"; @@ -82,7 +85,7 @@ EXPECT_NSEQ(disabledColor, cell.textLabel.textColor); } -TEST(SyncSwitchItemTest, PrepareForReuseClearsActions) { +TEST_F(SyncSwitchItemTest, PrepareForReuseClearsActions) { SyncSwitchCell* cell = [[SyncSwitchCell alloc] init]; UISwitch* switchView = cell.switchView; NSArray* target = [NSArray array]; diff --git a/ios/chrome/browser/ui/settings/cells/text_and_error_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/text_and_error_item_unittest.mm index 1106c7b83d2294..e4cdf8cc405696 100644 --- a/ios/chrome/browser/ui/settings/cells/text_and_error_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/text_and_error_item_unittest.mm @@ -7,6 +7,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,9 +15,11 @@ namespace { +using TextAndErrorItemTest = PlatformTest; + // Tests that the error UIImage and UILabels are set properly after a call to // |configureCell:|. -TEST(TextAndErrorItemTest, ImageViewAndLabels) { +TEST_F(TextAndErrorItemTest, ImageViewAndLabels) { TextAndErrorItem* item = [[TextAndErrorItem alloc] initWithType:0]; item.text = @"Test"; item.shouldDisplayError = YES; diff --git a/ios/chrome/browser/ui/settings/cells/version_item_unittest.mm b/ios/chrome/browser/ui/settings/cells/version_item_unittest.mm index b1b654f8d9e58d..eac2c61892db8c 100644 --- a/ios/chrome/browser/ui/settings/cells/version_item_unittest.mm +++ b/ios/chrome/browser/ui/settings/cells/version_item_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -14,7 +15,9 @@ namespace { -TEST(VersionItemTest, TextLabelGetsText) { +using VersionItemTest = PlatformTest; + +TEST_F(VersionItemTest, TextLabelGetsText) { VersionItem* item = [[VersionItem alloc] initWithType:0]; VersionCell* cell = [[[item cellClass] alloc] init]; EXPECT_TRUE([cell isMemberOfClass:[VersionCell class]]); diff --git a/ios/chrome/browser/ui/snackbar/snackbar_coordinator_unittest.mm b/ios/chrome/browser/ui/snackbar/snackbar_coordinator_unittest.mm index efb290511c20ff..e4fcd353d7fa4c 100644 --- a/ios/chrome/browser/ui/snackbar/snackbar_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/snackbar/snackbar_coordinator_unittest.mm @@ -7,6 +7,7 @@ #import "ios/chrome/browser/ui/commands/command_dispatcher.h" #import "ios/chrome/browser/ui/commands/snackbar_commands.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #include "third_party/ocmock/gtest_support.h" @@ -14,8 +15,10 @@ #error "This file requires ARC support." #endif +using SnackbarCoordinatorTest = PlatformTest; + // Tests that the coordinator handles snackbar commands. -TEST(SnackbarCoordinatorTest, RegistersDispatching) { +TEST_F(SnackbarCoordinatorTest, RegistersDispatching) { id dispatcher = OCMClassMock([CommandDispatcher class]); SnackbarCoordinator* coordinator = [[SnackbarCoordinator alloc] init]; coordinator.dispatcher = dispatcher; diff --git a/ios/chrome/browser/ui/stack_view/card_stack_layout_manager_unittest.mm b/ios/chrome/browser/ui/stack_view/card_stack_layout_manager_unittest.mm index 1d3a6c7683fce1..a942b6f6d9f597 100644 --- a/ios/chrome/browser/ui/stack_view/card_stack_layout_manager_unittest.mm +++ b/ios/chrome/browser/ui/stack_view/card_stack_layout_manager_unittest.mm @@ -45,8 +45,7 @@ - (void)setSize:(CGSize)size { namespace { -// Create a fixture to get an autorelease pool. -class CardStackLayoutManagerTest : public PlatformTest {}; +using CardStackLayoutManagerTest = PlatformTest; const float kMargin = 5; const float kMaxStagger = 40; diff --git a/ios/chrome/browser/ui/ui_util_unittest.mm b/ios/chrome/browser/ui/ui_util_unittest.mm index 1a2c2d390b4612..38c38c6e5f2781 100644 --- a/ios/chrome/browser/ui/ui_util_unittest.mm +++ b/ios/chrome/browser/ui/ui_util_unittest.mm @@ -10,12 +10,15 @@ #include "base/macros.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif -TEST(UIUtilTest, AlignToPixel) { +using UIUtilTest = PlatformTest; + +TEST_F(UIUtilTest, AlignToPixel) { CGFloat scale = [[UIScreen mainScreen] scale]; // Pick a few interesting values: already aligned, aligned on retina, and // some unaligned values that would round differently. Ensure that all are @@ -43,7 +46,7 @@ #define EXPECT_EQ_SIZE(a, b) \ EXPECT_NSEQ(NSStringFromCGSize(a), NSStringFromCGSize(b)) -TEST(UIUtilTest, TestProjectionFill) { +TEST_F(UIUtilTest, TestProjectionFill) { CGSize originalSize, targetSize, expectedRevisedSize, revisedSize; CGRect expectedProjection, projection; @@ -78,7 +81,7 @@ EXPECT_EQ_SIZE(expectedRevisedSize, revisedSize); } -TEST(UIUtilTest, TestProjectionFit) { +TEST_F(UIUtilTest, TestProjectionFit) { CGSize originalSize, targetSize, expectedRevisedSize, revisedSize; CGRect expectedProjection, projection; @@ -143,7 +146,7 @@ EXPECT_EQ_SIZE(expectedRevisedSize, revisedSize); } -TEST(UIUtilTest, TestProjectionAspectFill) { +TEST_F(UIUtilTest, TestProjectionAspectFill) { CGSize originalSize, targetSize, expectedRevisedSize, revisedSize; CGRect expectedProjection, projection; @@ -208,7 +211,7 @@ EXPECT_EQ_SIZE(expectedRevisedSize, revisedSize); } -TEST(UIUtilTest, TestProjectionAspectFillAlignTop) { +TEST_F(UIUtilTest, TestProjectionAspectFillAlignTop) { CGSize originalSize, targetSize, expectedRevisedSize, revisedSize; CGRect expectedProjection, projection; @@ -235,7 +238,7 @@ EXPECT_EQ_SIZE(expectedRevisedSize, revisedSize); } -TEST(UIUtilTest, TestProjectionAspectFillNoClipping) { +TEST_F(UIUtilTest, TestProjectionAspectFillNoClipping) { CGSize originalSize, targetSize, expectedRevisedSize, revisedSize; CGRect expectedProjection, projection; diff --git a/ios/chrome/browser/ui/uikit_ui_util_unittest.mm b/ios/chrome/browser/ui/uikit_ui_util_unittest.mm index 2016210af8a71b..084d82fad75d75 100644 --- a/ios/chrome/browser/ui/uikit_ui_util_unittest.mm +++ b/ios/chrome/browser/ui/uikit_ui_util_unittest.mm @@ -7,6 +7,7 @@ #include "base/strings/sys_string_conversions.h" #import "ios/chrome/browser/ui/ui_util.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -29,10 +30,12 @@ void ExpectInterpolatedColor(UIColor* firstColor, EXPECT_FLOAT_EQ(1.0, a); } +using UIKitUIUtilTest = PlatformTest; + // Verify the assumption about UIViewController that on iPad all orientations // are supported, and all orientations but Portrait Upside-Down on iPhone and // iPod Touch. -TEST(UIKitUIUtilTest, UIViewControllerSupportedOrientationsTest) { +TEST_F(UIKitUIUtilTest, UIViewControllerSupportedOrientationsTest) { UIViewController* viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil]; if (IsIPadIdiom()) { @@ -44,13 +47,13 @@ void ExpectInterpolatedColor(UIColor* firstColor, } } -TEST(UIKitUIUtilTest, TestGetUiFont) { +TEST_F(UIKitUIUtilTest, TestGetUiFont) { EXPECT_TRUE(GetUIFont(FONT_HELVETICA, false, 15.0)); EXPECT_TRUE(GetUIFont(FONT_HELVETICA_NEUE, true, 15.0)); } // Verifies that greyImage never returns retina-scale images. -TEST(UIKitUIUtilTest, TestGreyImage) { +TEST_F(UIKitUIUtilTest, TestGreyImage) { // Create an image using the device's scale factor. const CGSize kSize = CGSizeMake(100, 100); UIGraphicsBeginImageContextWithOptions(kSize, NO, 0.0); @@ -78,7 +81,7 @@ void ExpectInterpolatedColor(UIColor* firstColor, return image; } -TEST(UIKitUIUtilTest, TestResizeImageOpacity) { +TEST_F(UIKitUIUtilTest, TestResizeImageOpacity) { UIImage* actual; UIImage* image = testImage(CGSizeMake(100, 100)); actual = @@ -92,7 +95,7 @@ void ExpectInterpolatedColor(UIColor* firstColor, EXPECT_TRUE(ImageHasAlphaChannel(actual)); } -TEST(UIKitUIUtilTest, TestResizeImageInvalidInput) { +TEST_F(UIKitUIUtilTest, TestResizeImageInvalidInput) { UIImage* actual; UIImage* image = testImage(CGSizeMake(100, 50)); actual = ResizeImage(image, CGSizeZero, ProjectionMode::kAspectFit); @@ -109,7 +112,7 @@ void ExpectInterpolatedColor(UIColor* firstColor, EXPECT_FALSE(actual); } -TEST(UIKitUIUtilTest, TintImageKeepsImageProperties) { +TEST_F(UIKitUIUtilTest, TintImageKeepsImageProperties) { UIImage* image = testImage(CGSizeMake(100, 75)); UIImage* tintedImage = TintImage(image, [UIColor blueColor]); EXPECT_EQ(image.size.width, tintedImage.size.width); @@ -123,7 +126,7 @@ void ExpectInterpolatedColor(UIColor* firstColor, tintedImage.flipsForRightToLeftLayoutDirection); } -TEST(UIKitUIUtilTest, TestInterpolateFromColorToColor) { +TEST_F(UIKitUIUtilTest, TestInterpolateFromColorToColor) { CGFloat colorOne = 50.0f / 255.0f; CGFloat colorTwo = 100.0f / 255.0f; CGFloat expectedOne = 50.0f / 255.0f; @@ -142,7 +145,7 @@ void ExpectInterpolatedColor(UIColor* firstColor, } // Tests that InterpolateFromColorToColor() works for monochrome colors. -TEST(UIKitUIUtilTest, TestInterpolateFromColorToColorMonochrome) { +TEST_F(UIKitUIUtilTest, TestInterpolateFromColorToColorMonochrome) { CGFloat kRGBComponent = 0.2; UIColor* rgb = [UIColor colorWithRed:kRGBComponent green:kRGBComponent diff --git a/ios/chrome/browser/ui/util/constraints_ui_util_unittest.mm b/ios/chrome/browser/ui/util/constraints_ui_util_unittest.mm index e79697c5b866e7..0a8644cf2e648c 100644 --- a/ios/chrome/browser/ui/util/constraints_ui_util_unittest.mm +++ b/ios/chrome/browser/ui/util/constraints_ui_util_unittest.mm @@ -14,9 +14,11 @@ namespace { +using ConstraintsUIUtilTest = PlatformTest; + // Tests that SafeAreaLayoutGuideForView returns and attach a single // safeAreaLayoutGuide before iOS 11. -TEST(ConstraintsUIUtilTest, SafeAreaLayoutGuideForView) { +TEST_F(ConstraintsUIUtilTest, SafeAreaLayoutGuideForView) { if (@available(iOS 11, *)) { } else { UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; diff --git a/ios/chrome/browser/ui/util/core_text_util_unittest.mm b/ios/chrome/browser/ui/util/core_text_util_unittest.mm index e56a3547700d5a..911f31568c889c 100644 --- a/ios/chrome/browser/ui/util/core_text_util_unittest.mm +++ b/ios/chrome/browser/ui/util/core_text_util_unittest.mm @@ -16,8 +16,10 @@ // TODO(crbug.com/601772): Add tests for other core_text_util tests. +using CoreTextUtilTest = PlatformTest; + // Tests that the minimum line height attribute is reflected in GetLineHeight(). -TEST(CoreTextUtilTest, MinLineHeightText) { +TEST_F(CoreTextUtilTest, MinLineHeightText) { CGFloat min_line_height = 30.0; NSMutableParagraphStyle* style = [[NSMutableParagraphStyle alloc] init]; [style setMinimumLineHeight:min_line_height]; @@ -29,7 +31,7 @@ } // Tests that the maximum line height attribute is reflected in GetLineHeight(). -TEST(CoreTextUtilTest, MaxLineHeightText) { +TEST_F(CoreTextUtilTest, MaxLineHeightText) { CGFloat max_line_height = 10.0; NSMutableParagraphStyle* style = [[NSMutableParagraphStyle alloc] init]; [style setMaximumLineHeight:max_line_height]; @@ -42,7 +44,7 @@ // Tests that the line height multiple attribute is reflected in // GetLineHeight(). -TEST(CoreTextUtilTest, LineHeightMultipleTest) { +TEST_F(CoreTextUtilTest, LineHeightMultipleTest) { UIFont* font = [UIFont systemFontOfSize:20.0]; CGFloat font_line_height = font.ascender - font.descender; CGFloat line_height_multiple = 2.0; diff --git a/ios/chrome/browser/ui/util/named_guide_unittest.mm b/ios/chrome/browser/ui/util/named_guide_unittest.mm index 01b5aacd432ca6..26476d678e5d2b 100644 --- a/ios/chrome/browser/ui/util/named_guide_unittest.mm +++ b/ios/chrome/browser/ui/util/named_guide_unittest.mm @@ -6,13 +6,16 @@ #include "base/logging.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using NamedGuideTest = PlatformTest; + // Tests that guides are reachable after being added to a view. -TEST(NamedGuideTest, TestAddAndFind) { +TEST_F(NamedGuideTest, TestAddAndFind) { GuideName* test_guide = @"NamedGuideTest"; UIView* view = [[UIView alloc] init]; @@ -24,7 +27,7 @@ } // Tests that guides added to a child view are not reachable from the parent. -TEST(NamedGuideTest, TestGuideOnChild) { +TEST_F(NamedGuideTest, TestGuideOnChild) { GuideName* test_guide = @"NamedGuideTest"; UIView* view = [[UIView alloc] init]; @@ -38,7 +41,7 @@ } // Tests that children can reach guides that are added to ancestors. -TEST(NamedGuideTest, TestGuideOnAncestor) { +TEST_F(NamedGuideTest, TestGuideOnAncestor) { GuideName* test_guide = @"NamedGuideTest"; UIView* view = [[UIView alloc] init]; diff --git a/ios/chrome/browser/update_client/ios_chrome_update_query_params_delegate_unittest.cc b/ios/chrome/browser/update_client/ios_chrome_update_query_params_delegate_unittest.cc index b6b0a4d7ce20f4..c8edc948514a49 100644 --- a/ios/chrome/browser/update_client/ios_chrome_update_query_params_delegate_unittest.cc +++ b/ios/chrome/browser/update_client/ios_chrome_update_query_params_delegate_unittest.cc @@ -13,6 +13,7 @@ #include "components/version_info/version_info.h" #include "ios/chrome/common/channel_info.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" using base::StringPrintf; @@ -48,7 +49,9 @@ void TestParams(update_client::UpdateQueryParams::ProdId prod_id) { IOSChromeUpdateQueryParamsDelegate::GetLang().c_str()))); } -TEST(IOSChromeUpdateQueryParamsDelegateTest, GetParams) { +using IOSChromeUpdateQueryParamsDelegateTest = PlatformTest; + +TEST_F(IOSChromeUpdateQueryParamsDelegateTest, GetParams) { base::ScopedClosureRunner runner( base::Bind(update_client::UpdateQueryParams::SetDelegate, nullptr)); update_client::UpdateQueryParams::SetDelegate( diff --git a/ios/chrome/browser/voice/text_to_speech_parser_unittest.mm b/ios/chrome/browser/voice/text_to_speech_parser_unittest.mm index 8ac971b172e371..5616cb73a5c3f5 100644 --- a/ios/chrome/browser/voice/text_to_speech_parser_unittest.mm +++ b/ios/chrome/browser/voice/text_to_speech_parser_unittest.mm @@ -6,6 +6,7 @@ #import "ios/chrome/browser/voice/text_to_speech_parser.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #import "third_party/google_toolbox_for_mac/src/Foundation/GTMStringEncoding.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -21,7 +22,9 @@ NSString* const kInvalidVoiceSearchHTML = @"no TTS data"; } // namespace -TEST(TextToSpeechParser, ExtractAudioDataValid) { +using TextToSpeechParser = PlatformTest; + +TEST_F(TextToSpeechParser, ExtractAudioDataValid) { NSData* result = ExtractVoiceSearchAudioDataFromPageHTML(kValidVoiceSearchHTML); @@ -32,7 +35,7 @@ EXPECT_TRUE([expectedData isEqualToData:result]); } -TEST(TextToSpeechParser, ExtractAudioDataNotFound) { +TEST_F(TextToSpeechParser, ExtractAudioDataNotFound) { NSData* result = ExtractVoiceSearchAudioDataFromPageHTML(kInvalidVoiceSearchHTML); EXPECT_TRUE(result == nil); diff --git a/ios/chrome/browser/web/external_app_launcher_unittest.mm b/ios/chrome/browser/web/external_app_launcher_unittest.mm index 5251de9fb1f157..09ff757fcba98f 100644 --- a/ios/chrome/browser/web/external_app_launcher_unittest.mm +++ b/ios/chrome/browser/web/external_app_launcher_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -19,7 +20,9 @@ + (NSString*)formatCallArgument:(NSURL*)url; namespace { -TEST(ExternalAppLauncherTest, TestBadFormatCallArgument) { +using ExternalAppLauncherTest = PlatformTest; + +TEST_F(ExternalAppLauncherTest, TestBadFormatCallArgument) { EXPECT_NSEQ(@"garbage:", [ExternalAppLauncher formatCallArgument:[NSURL URLWithString:@"garbage:"]]); @@ -28,7 +31,7 @@ + (NSString*)formatCallArgument:(NSURL*)url; formatCallArgument:[NSURL URLWithString:@"malformed:////"]]); } -TEST(ExternalAppLauncherTest, TestFormatCallArgument) { +TEST_F(ExternalAppLauncherTest, TestFormatCallArgument) { EXPECT_NSEQ( @"+1234", [ExternalAppLauncher @@ -46,7 +49,7 @@ + (NSString*)formatCallArgument:(NSURL*)url; formatCallArgument:[NSURL URLWithString:@"garbage:75009"]]); } -TEST(ExternalAppLauncherTest, TestURLEscapedArgument) { +TEST_F(ExternalAppLauncherTest, TestURLEscapedArgument) { EXPECT_NSEQ(@"+1 650 555 1212", [ExternalAppLauncher formatCallArgument: diff --git a/ios/chrome/browser/web/mailto_handler_gmail_unittest.mm b/ios/chrome/browser/web/mailto_handler_gmail_unittest.mm index d5c5266428f68f..93ba9a7cee9eea 100644 --- a/ios/chrome/browser/web/mailto_handler_gmail_unittest.mm +++ b/ios/chrome/browser/web/mailto_handler_gmail_unittest.mm @@ -6,12 +6,15 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif -TEST(MailtoHandlerGmailTest, TestConstructor) { +using MailtoHandlerGmailTest = PlatformTest; + +TEST_F(MailtoHandlerGmailTest, TestConstructor) { MailtoHandlerGmail* handler = [[MailtoHandlerGmail alloc] init]; EXPECT_NSEQ(@"Gmail", [handler appName]); EXPECT_NSEQ(@"422689480", [handler appStoreID]); diff --git a/ios/chrome/browser/web/mailto_handler_inbox_unittest.mm b/ios/chrome/browser/web/mailto_handler_inbox_unittest.mm index 856097c899fecf..98b1521775a3ed 100644 --- a/ios/chrome/browser/web/mailto_handler_inbox_unittest.mm +++ b/ios/chrome/browser/web/mailto_handler_inbox_unittest.mm @@ -6,12 +6,15 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif -TEST(MailtoHandlerInboxTest, TestConstructor) { +using MailtoHandlerInboxTest = PlatformTest; + +TEST_F(MailtoHandlerInboxTest, TestConstructor) { MailtoHandlerInbox* handler = [[MailtoHandlerInbox alloc] init]; EXPECT_NSEQ(@"Inbox by Gmail", [handler appName]); EXPECT_NSEQ(@"905060486", [handler appStoreID]); diff --git a/ios/chrome/browser/web/mailto_handler_system_mail_unittest.mm b/ios/chrome/browser/web/mailto_handler_system_mail_unittest.mm index 86bb5c9f215507..1ee8beab25ecbc 100644 --- a/ios/chrome/browser/web/mailto_handler_system_mail_unittest.mm +++ b/ios/chrome/browser/web/mailto_handler_system_mail_unittest.mm @@ -6,13 +6,16 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif -TEST(MailtoHandlerSystemMailTest, TestConstructor) { +using MailtoHandlerSystemMailTest = PlatformTest; + +TEST_F(MailtoHandlerSystemMailTest, TestConstructor) { MailtoHandler* handler = [[MailtoHandlerSystemMail alloc] init]; EXPECT_TRUE(handler); EXPECT_NSEQ(@"Mail", [handler appName]); @@ -20,7 +23,7 @@ EXPECT_TRUE([handler isAvailable]); } -TEST(MailtoHandlerSystemMailTest, TestRewrite) { +TEST_F(MailtoHandlerSystemMailTest, TestRewrite) { MailtoHandler* handler = [[MailtoHandlerSystemMail alloc] init]; NSString* result = [handler rewriteMailtoURL:GURL("mailto:user@domain.com")]; EXPECT_NSEQ(@"mailto:user@domain.com", result); diff --git a/ios/chrome/browser/web/mailto_handler_unittest.mm b/ios/chrome/browser/web/mailto_handler_unittest.mm index 18e4375c4070cb..4a10a9ace3649c 100644 --- a/ios/chrome/browser/web/mailto_handler_unittest.mm +++ b/ios/chrome/browser/web/mailto_handler_unittest.mm @@ -6,14 +6,17 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using MailtoHandlerTest = PlatformTest; + // Tests constructor. -TEST(MailtoHandlerTest, TestConstructor) { +TEST_F(MailtoHandlerTest, TestConstructor) { MailtoHandler* handler = [[MailtoHandler alloc] initWithName:@"Some App" appStoreID:@"12345"]; EXPECT_NSEQ(@"Some App", [handler appName]); @@ -22,7 +25,7 @@ } // Tests mailto URL with and without a subject. -TEST(MailtoHandlerTest, TestRewriteGood) { +TEST_F(MailtoHandlerTest, TestRewriteGood) { MailtoHandler* handler = [[MailtoHandler alloc] initWithName:@"Some App" appStoreID:@"12345"]; NSString* result = [handler rewriteMailtoURL:GURL("mailto:user@domain.com")]; @@ -34,7 +37,7 @@ } // Tests mailto URL with unrecognized query parameters. -TEST(MailtoHandlerTest, TestRewriteUnrecognizedParams) { +TEST_F(MailtoHandlerTest, TestRewriteUnrecognizedParams) { MailtoHandler* handler = [[MailtoHandler alloc] initWithName:@"Some App" appStoreID:@"12345"]; NSString* result = [handler @@ -44,7 +47,7 @@ } // Tests mailto URL with a body that includes a = sign. -TEST(MailtoHandlerTest, TestRewriteBodyWithUrl) { +TEST_F(MailtoHandlerTest, TestRewriteBodyWithUrl) { MailtoHandler* handler = [[MailtoHandler alloc] initWithName:@"Some App" appStoreID:@"12345"]; NSString* result = [handler @@ -54,7 +57,7 @@ } // Tests mailto URL with parameters that are mixed upper/lower cases. -TEST(MailtoHandlerTest, TestRewriteWithMixedCase) { +TEST_F(MailtoHandlerTest, TestRewriteWithMixedCase) { MailtoHandler* handler = [[MailtoHandler alloc] initWithName:@"Some App" appStoreID:@"12345"]; NSString* result = @@ -63,7 +66,7 @@ } // Tests that non-mailto URLs returns nil. -TEST(MailtoHandlerTest, TestRewriteNotMailto) { +TEST_F(MailtoHandlerTest, TestRewriteNotMailto) { MailtoHandler* handler = [[MailtoHandler alloc] initWithName:@"Some App" appStoreID:@"12345"]; NSString* result = [handler rewriteMailtoURL:GURL("http://www.google.com")]; diff --git a/ios/chrome/browser/web/network_activity_indicator_tab_helper_unittest.mm b/ios/chrome/browser/web/network_activity_indicator_tab_helper_unittest.mm index 1898532355f6b0..cf0203172fa136 100644 --- a/ios/chrome/browser/web/network_activity_indicator_tab_helper_unittest.mm +++ b/ios/chrome/browser/web/network_activity_indicator_tab_helper_unittest.mm @@ -9,6 +9,7 @@ #import "ios/web/public/test/fakes/test_web_state.h" #import "ios/web/public/test/web_test.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -16,9 +17,11 @@ using web::TestWebState; +using NetworkActivityIndicatorTabHelperTest = PlatformTest; + // Tests that the network activity for a single WebState correctly manages // the state of the network activity indicator. -TEST(NetworkActivityIndicatorTabHelperTest, SingleWebStateActivity) { +TEST_F(NetworkActivityIndicatorTabHelperTest, SingleWebStateActivity) { std::unique_ptr web_state(new TestWebState()); NetworkActivityIndicatorTabHelper::CreateForWebState(web_state.get(), @"web_state1"); @@ -37,7 +40,7 @@ // Tests that the network activity for multiple WebStates correctly manage // the state of the network activity indicator. -TEST(NetworkActivityIndicatorTabHelperTest, MultipleWebStateActivity) { +TEST_F(NetworkActivityIndicatorTabHelperTest, MultipleWebStateActivity) { std::unique_ptr web_state1(new TestWebState()); NetworkActivityIndicatorTabHelper::CreateForWebState(web_state1.get(), @"web_state1"); @@ -65,7 +68,7 @@ // Tests that the network activity for a single WebState correctly stops when // the WebState is deallocated. -TEST(NetworkActivityIndicatorTabHelperTest, WebStateDeallocated) { +TEST_F(NetworkActivityIndicatorTabHelperTest, WebStateDeallocated) { std::unique_ptr web_state(new TestWebState()); NetworkActivityIndicatorTabHelper::CreateForWebState(web_state.get(), @"web_state1"); diff --git a/ios/chrome/browser/web_resource/web_resource_util_unittest.cc b/ios/chrome/browser/web_resource/web_resource_util_unittest.cc index ac1950a8a94f99..decd97a25dfb8a 100644 --- a/ios/chrome/browser/web_resource/web_resource_util_unittest.cc +++ b/ios/chrome/browser/web_resource/web_resource_util_unittest.cc @@ -15,10 +15,11 @@ #include "base/values.h" #include "ios/web/public/web_thread.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" namespace web_resource { -class WebResourceUtilTest : public testing::Test { +class WebResourceUtilTest : public PlatformTest { protected: WebResourceUtilTest() : error_called_(false), success_called_(false) {} ~WebResourceUtilTest() override {} diff --git a/ios/chrome/common/ns_regular_expression_unittest.mm b/ios/chrome/common/ns_regular_expression_unittest.mm index d19f476b3df0b3..022ac6313705cb 100644 --- a/ios/chrome/common/ns_regular_expression_unittest.mm +++ b/ios/chrome/common/ns_regular_expression_unittest.mm @@ -64,13 +64,15 @@ void ExpectRegexNotMatched(NSRegularExpression* regex, NSString* testString) { error:&error]; } -TEST(NSRegularExpressionTest, TestSimpleRegex) { +using NSRegularExpressionTest = PlatformTest; + +TEST_F(NSRegularExpressionTest, TestSimpleRegex) { NSRegularExpression* regex = MakeRegularExpression(@"foo(.*)bar(.*)"); ExpectRegexMatched(regex, @"fooONEbarTWO", @"first $1, second $2", @"first ONE, second TWO"); } -TEST(NSRegularExpressionTest, TestComplexRegex) { +TEST_F(NSRegularExpressionTest, TestComplexRegex) { NSString* expression = @"^http[s]?://" "(?:" "(?:youtu\\.be/)|" @@ -89,7 +91,7 @@ void ExpectRegexNotMatched(NSRegularExpression* regex, NSString* testString) { ExpectRegexNotMatched(regex, @"http://www.youtube.com/embed/GkOZ8DfO248"); } -TEST(NSRegularExpressionTest, TestSimpleAlternation) { +TEST_F(NSRegularExpressionTest, TestSimpleAlternation) { // This test verifies how NSRegularExpression works. // Regex 'ab|c' matches 'ab', 'ac', or 'c'. Does not match 'abc', 'a', or 'b'. NSRegularExpression* regex = MakeRegularExpression(@"^ab|c$"); @@ -115,7 +117,7 @@ void ExpectRegexNotMatched(NSRegularExpression* regex, NSString* testString) { ExpectRegexNotMatched(regex, @"abc"); } -TEST(NSRegularExpressionTest, TestUberCaptureGroup) { +TEST_F(NSRegularExpressionTest, TestUberCaptureGroup) { // The absence of an uber-capture group caused NSRegularExpression to crash on // iOS 5.x. This tests to make sure that it is not happening on iOS 6+ // environments. diff --git a/ios/chrome/common/string_util_unittest.mm b/ios/chrome/common/string_util_unittest.mm index 07dc1108ca29f9..98f47723d2c155 100644 --- a/ios/chrome/common/string_util_unittest.mm +++ b/ios/chrome/common/string_util_unittest.mm @@ -16,7 +16,9 @@ namespace { -TEST(StringUtilTest, ParseStringWithLink) { +using StringUtilTest = PlatformTest; + +TEST_F(StringUtilTest, ParseStringWithLink) { NSArray* const all_test_data = @[ @{ @"input" : @"Text without link.", @@ -60,7 +62,7 @@ } } -TEST(StringUtilTest, CleanNSStringForDisplay) { +TEST_F(StringUtilTest, CleanNSStringForDisplay) { NSArray* const all_test_data = @[ @{ @"input" : @"Clean String", @@ -99,7 +101,9 @@ } } -TEST(StringUnitTest, SubstringOfWidth) { +using StringUnitTest = PlatformTest; + +TEST_F(StringUnitTest, SubstringOfWidth) { // returns nil for zero-length strings EXPECT_NSEQ(SubstringOfWidth(@"", @{}, 100, NO), nil); EXPECT_NSEQ(SubstringOfWidth(nil, @{}, 100, NO), nil); diff --git a/ios/chrome/common/x_callback_url_unittest.cc b/ios/chrome/common/x_callback_url_unittest.cc index f4452886f15de3..559208f6fbbb62 100644 --- a/ios/chrome/common/x_callback_url_unittest.cc +++ b/ios/chrome/common/x_callback_url_unittest.cc @@ -6,6 +6,7 @@ #include "base/strings/stringprintf.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" namespace { @@ -20,7 +21,9 @@ struct XCallbackURLEncodeTestCase { const char* expected; }; -TEST(XCallbackURLTest, IsXCallbackURL) { +using XCallbackURLTest = PlatformTest; + +TEST_F(XCallbackURLTest, IsXCallbackURL) { EXPECT_TRUE(IsXCallbackURL(GURL("chrome://x-callback-url"))); EXPECT_TRUE(IsXCallbackURL(GURL("https://x-callback-url"))); EXPECT_TRUE(IsXCallbackURL(GURL("exotic-scheme://x-callback-url"))); @@ -34,7 +37,7 @@ TEST(XCallbackURLTest, IsXCallbackURL) { EXPECT_FALSE(IsXCallbackURL(GURL("https://www.google.com"))); } -TEST(XCallbackURLTest, URLWithScheme) { +TEST_F(XCallbackURLTest, URLWithScheme) { const XCallbackURLEncodeTestCase test_cases[] = { { "chrome", @@ -121,7 +124,7 @@ struct XCallbackURLDecodeTestCase { std::map expected; }; -TEST(XCallbackURLTest, QueryParameters) { +TEST_F(XCallbackURLTest, QueryParameters) { const XCallbackURLDecodeTestCase test_cases[] = { { GURL("chrome://x-callback-url/"), diff --git a/ios/chrome/test/base/scoped_block_swizzler_unittest.mm b/ios/chrome/test/base/scoped_block_swizzler_unittest.mm index 111cf104f95be9..2af049cbe7b24f 100644 --- a/ios/chrome/test/base/scoped_block_swizzler_unittest.mm +++ b/ios/chrome/test/base/scoped_block_swizzler_unittest.mm @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/mac/foundation_util.h" #include "ios/chrome/test/base/scoped_block_swizzler.h" +#include "base/mac/foundation_util.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" #include "testing/platform_test.h" @@ -29,8 +29,10 @@ - (NSString*)instanceMethodToSwizzle; NSString* const kOriginalInstanceValue = @"Bizz"; NSString* const kSwizzledInstanceValue = @"Buzz"; +using ScopedBlockSwizzlerTest = PlatformTest; + // Tests that swizzling a class method works properly. -TEST(ScopedBlockSwizzlerTest, SwizzlingClassMethods) { +TEST_F(ScopedBlockSwizzlerTest, SwizzlingClassMethods) { EXPECT_NSEQ(kOriginalClassValue, [ScopedBlockSwizzlerTestClass classMethodToSwizzle]); @@ -47,7 +49,7 @@ ScopedBlockSwizzler swizzler([ScopedBlockSwizzlerTestClass class], } // Tests that swizzling an instance method works properly. -TEST(ScopedBlockSwizzlerTest, SwizzlingInstanceMethod) { +TEST_F(ScopedBlockSwizzlerTest, SwizzlingInstanceMethod) { ScopedBlockSwizzlerTestClass* target = [[ScopedBlockSwizzlerTestClass alloc] init]; target.value = kSwizzledInstanceValue; @@ -71,7 +73,7 @@ ScopedBlockSwizzler swizzler([ScopedBlockSwizzlerTestClass class], // Tests that calling |ScopedBlockSwizzler::reset()| properly unswizzles the // method. -TEST(ScopedBlockSwizzlerTest, TestReset) { +TEST_F(ScopedBlockSwizzlerTest, TestReset) { EXPECT_NSEQ(kOriginalClassValue, [ScopedBlockSwizzlerTestClass classMethodToSwizzle]); diff --git a/ios/chrome/test/google_toolbox_unittest.mm b/ios/chrome/test/google_toolbox_unittest.mm index 196afd4b70fa61..a2640361f67b78 100644 --- a/ios/chrome/test/google_toolbox_unittest.mm +++ b/ios/chrome/test/google_toolbox_unittest.mm @@ -6,15 +6,18 @@ #include "base/logging.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #import "third_party/google_toolbox_for_mac/src/Foundation/GTMNSDictionary+URLArguments.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using GoogleToolboxForMacTest = PlatformTest; + // [NSDictionary gtm_dictionaryWithHttpArgumentsString] is used downstream. // This test ensures that we keep compiling the file. -TEST(GoogleToolboxForMacTest, dictionaryWithHttpArgumentsString) { +TEST_F(GoogleToolboxForMacTest, dictionaryWithHttpArgumentsString) { NSDictionary* dict = [NSDictionary gtm_dictionaryWithHttpArgumentsString:@""]; EXPECT_EQ(0u, [dict count]); } diff --git a/ios/clean/chrome/app/steps/phased_step_runner_unittest.mm b/ios/clean/chrome/app/steps/phased_step_runner_unittest.mm index 25994184883eb2..f7489ca4ed1102 100644 --- a/ios/clean/chrome/app/steps/phased_step_runner_unittest.mm +++ b/ios/clean/chrome/app/steps/phased_step_runner_unittest.mm @@ -94,7 +94,9 @@ - (void)runFeature:(NSString*)feature withContext:(id)context { @end -TEST(PhasedStepRunnerTest, TestUnexecutedSteps) { +using PhasedStepRunnerTest = PlatformTest; + +TEST_F(PhasedStepRunnerTest, TestUnexecutedSteps) { TestStep* step1 = [[TestStep alloc] init]; step1.providedFeature = @"feature_a"; @@ -125,7 +127,7 @@ - (void)runFeature:(NSString*)feature withContext:(id)context { } // Simple dependency chain A-> B-> C -TEST(PhasedStepRunnerTest, TestSimpleDependencies) { +TEST_F(PhasedStepRunnerTest, TestSimpleDependencies) { TestStep* step1 = [[TestStep alloc] init]; step1.providedFeature = @"feature_a"; @@ -157,7 +159,7 @@ - (void)runFeature:(NSString*)feature withContext:(id)context { } // Dependency graph: A->B; B->C; B->D, C->D. -TEST(PhasedStepRunnerTest, TestDependencyGraph) { +TEST_F(PhasedStepRunnerTest, TestDependencyGraph) { TestStep* step1 = [[TestStep alloc] init]; step1.providedFeature = @"feature_a"; @@ -194,7 +196,7 @@ - (void)runFeature:(NSString*)feature withContext:(id)context { EXPECT_TRUE(task4.hasRun); } -TEST(PhasedStepRunnerTest, TestOneAsyncAction) { +TEST_F(PhasedStepRunnerTest, TestOneAsyncAction) { AsyncTestStep* step1 = [[AsyncTestStep alloc] init]; step1.providedFeature = @"feature_a"; NSUInteger testPhase = 1; @@ -209,7 +211,7 @@ - (void)runFeature:(NSString*)feature withContext:(id)context { EXPECT_TRUE(step1.hasRun); } -TEST(PhasedStepRunnerTest, TestAsyncDependencies) { +TEST_F(PhasedStepRunnerTest, TestAsyncDependencies) { AsyncTestStep* step1 = [[AsyncTestStep alloc] init]; step1.providedFeature = @"feature_a"; @@ -240,7 +242,7 @@ - (void)runFeature:(NSString*)feature withContext:(id)context { EXPECT_TRUE(task3.hasRun); } -TEST(PhasedStepRunnerTest, TestManyDependencies) { +TEST_F(PhasedStepRunnerTest, TestManyDependencies) { NSMutableArray* tasks = [[NSMutableArray alloc] init]; AsyncTestStep* root_task = [[AsyncTestStep alloc] init]; root_task.providedFeature = @"feature_a"; @@ -305,7 +307,7 @@ - (void)runFeature:(NSString*)feature withContext:(id)context { } // Simple phase change -TEST(PhasedStepRunnerTest, TestPhaseChangeInStep) { +TEST_F(PhasedStepRunnerTest, TestPhaseChangeInStep) { TestStep* step1 = [[TestStep alloc] init]; step1.providedFeature = @"feature_a"; @@ -346,7 +348,7 @@ - (void)runFeature:(NSString*)feature withContext:(id)context { } // Sync phase change with async tasks -TEST(PhasedStepRunnerTest, TestPhaseChangeInStepWithAsync) { +TEST_F(PhasedStepRunnerTest, TestPhaseChangeInStepWithAsync) { TestStep* step1 = [[AsyncTestStep alloc] init]; step1.providedFeature = @"feature_a"; diff --git a/ios/clean/chrome/browser/ui/dialogs/context_menu/context_menu_dialog_mediator_unittest.mm b/ios/clean/chrome/browser/ui/dialogs/context_menu/context_menu_dialog_mediator_unittest.mm index 26f671d10580f0..165d7479b45c26 100644 --- a/ios/clean/chrome/browser/ui/dialogs/context_menu/context_menu_dialog_mediator_unittest.mm +++ b/ios/clean/chrome/browser/ui/dialogs/context_menu/context_menu_dialog_mediator_unittest.mm @@ -12,14 +12,17 @@ #import "ios/web/public/web_state/context_menu_params.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using ContextMenuDialogMediatorTest = PlatformTest; + // Tests context menu setup for a request with no URLs. -TEST(ContextMenuDialogMediatorTest, NoURLs) { +TEST_F(ContextMenuDialogMediatorTest, NoURLs) { // Create a context with |kMenuTitle|. NSString* kMenuTitle = @"Menu Title"; web::ContextMenuParams params; @@ -39,7 +42,7 @@ } // Tests that the script button is shown for javacript: scheme URLs. -TEST(ContextMenuDialogMediatorTest, ScriptItem) { +TEST_F(ContextMenuDialogMediatorTest, ScriptItem) { // Create a context with |kJavaScriptURL|. GURL kJavaScriptURL("javascript:alert('test');"); web::ContextMenuParams params; @@ -56,7 +59,7 @@ } // Tests that the link options are shown for valid link URLs. -TEST(ContextMenuDialogMediatorTest, LinkItems) { +TEST_F(ContextMenuDialogMediatorTest, LinkItems) { // Create a context with a valid link URL. web::ContextMenuParams params; params.link_url = GURL("http://valid.url.com"); @@ -80,7 +83,7 @@ } // Tests that the image options are shown for valid image URLs. -TEST(ContextMenuDialogMediatorTest, ImageItems) { +TEST_F(ContextMenuDialogMediatorTest, ImageItems) { // Create a context with a valid image URL. web::ContextMenuParams params; params.src_url = GURL("http://valid.url.com"); diff --git a/ios/clean/chrome/browser/ui/dialogs/dialog_button_configuration_unittest.mm b/ios/clean/chrome/browser/ui/dialogs/dialog_button_configuration_unittest.mm index 114acf3ef6109e..bb29407481ac6f 100644 --- a/ios/clean/chrome/browser/ui/dialogs/dialog_button_configuration_unittest.mm +++ b/ios/clean/chrome/browser/ui/dialogs/dialog_button_configuration_unittest.mm @@ -8,6 +8,7 @@ #import "ios/clean/chrome/browser/ui/dialogs/dialog_configuration_identifier.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -19,9 +20,11 @@ const DialogButtonStyle kButtonStyle = DialogButtonStyle::DESTRUCTIVE; } +using DialogButtonConfigurationTest = PlatformTest; + // Tests that the values passed to the factory method are reflected in the // returned value. -TEST(DialogButtonConfigurationTest, FactoryMethod) { +TEST_F(DialogButtonConfigurationTest, FactoryMethod) { DialogButtonConfiguration* config = [DialogButtonConfiguration configWithText:kButtonText style:kButtonStyle]; EXPECT_NSEQ(kButtonText, config.text); @@ -30,7 +33,7 @@ // Tests that two DialogButtonConfigurations created with the same values have // unequal identifiers. -TEST(DialogButtonConfigurationTest, Identifiers) { +TEST_F(DialogButtonConfigurationTest, Identifiers) { DialogButtonConfiguration* config1 = [DialogButtonConfiguration configWithText:kButtonText style:kButtonStyle]; DialogButtonConfiguration* config2 = diff --git a/ios/clean/chrome/browser/ui/dialogs/dialog_configuration_identifier_unittest.mm b/ios/clean/chrome/browser/ui/dialogs/dialog_configuration_identifier_unittest.mm index c14726a3c60721..4dcd2cfc3b294c 100644 --- a/ios/clean/chrome/browser/ui/dialogs/dialog_configuration_identifier_unittest.mm +++ b/ios/clean/chrome/browser/ui/dialogs/dialog_configuration_identifier_unittest.mm @@ -6,14 +6,17 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using DialogConfigurationIdentifierTest = PlatformTest; + // Tests that two DialogConfigurationIdentifiers created sequentially are not // equal to each other. -TEST(DialogConfigurationIdentifierTest, NotEqual) { +TEST_F(DialogConfigurationIdentifierTest, NotEqual) { DialogConfigurationIdentifier* ID1 = [[DialogConfigurationIdentifier alloc] init]; DialogConfigurationIdentifier* ID2 = @@ -23,7 +26,7 @@ // Tests that copying a DialogConfigurationIdentifier creates one that is equal // to the original. -TEST(DialogConfigurationIdentifierTest, EqualCopies) { +TEST_F(DialogConfigurationIdentifierTest, EqualCopies) { DialogConfigurationIdentifier* identifier = [[DialogConfigurationIdentifier alloc] init]; DialogConfigurationIdentifier* copy = [identifier copy]; diff --git a/ios/clean/chrome/browser/ui/dialogs/dialog_text_field_configuration_unittest.mm b/ios/clean/chrome/browser/ui/dialogs/dialog_text_field_configuration_unittest.mm index a39f90e951ac3f..4afa494bc6e770 100644 --- a/ios/clean/chrome/browser/ui/dialogs/dialog_text_field_configuration_unittest.mm +++ b/ios/clean/chrome/browser/ui/dialogs/dialog_text_field_configuration_unittest.mm @@ -7,6 +7,7 @@ #import "ios/clean/chrome/browser/ui/dialogs/dialog_configuration_identifier.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -19,9 +20,11 @@ const BOOL kSecure = YES; } +using DialogTextFieldConfigurationTest = PlatformTest; + // Tests that the values passed to the factory method are reflected in the // returned value. -TEST(DialogTextFieldConfigurationTest, FactoryMethod) { +TEST_F(DialogTextFieldConfigurationTest, FactoryMethod) { DialogTextFieldConfiguration* config = [DialogTextFieldConfiguration configWithDefaultText:kDefaultText placeholderText:kPlaceholderText @@ -33,7 +36,7 @@ // Tests that two DialogTextFieldConfigurations created with the same values // have unequal identifiers. -TEST(DialogTextFieldConfigurationTest, Identifiers) { +TEST_F(DialogTextFieldConfigurationTest, Identifiers) { DialogTextFieldConfiguration* config1 = [DialogTextFieldConfiguration configWithDefaultText:kDefaultText placeholderText:kPlaceholderText diff --git a/ios/clean/chrome/browser/ui/dialogs/dialog_view_controller_unittest.mm b/ios/clean/chrome/browser/ui/dialogs/dialog_view_controller_unittest.mm index d9a2968f997192..3c842b635546f1 100644 --- a/ios/clean/chrome/browser/ui/dialogs/dialog_view_controller_unittest.mm +++ b/ios/clean/chrome/browser/ui/dialogs/dialog_view_controller_unittest.mm @@ -10,13 +10,16 @@ #import "ios/clean/chrome/browser/ui/dialogs/test_helpers/dialog_test_util.h" #import "ios/clean/chrome/browser/ui/dialogs/test_helpers/test_dialog_view_controller.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using DialogViewControllerTest = PlatformTest; + // Tests that the dialog is properly set up via the DialogConsumer API. -TEST(DialogViewControllerTest, VerifySetup) { +TEST_F(DialogViewControllerTest, VerifySetup) { NSString* const kTitle = @"Title"; NSString* const kMessage = @"message"; NSArray* const kButtonConfigs = @[ [DialogButtonConfiguration diff --git a/ios/clean/chrome/browser/ui/dialogs/unavailable_feature_dialogs/unavailable_feature_dialog_mediator_unittest.mm b/ios/clean/chrome/browser/ui/dialogs/unavailable_feature_dialogs/unavailable_feature_dialog_mediator_unittest.mm index 9f90c391060dc9..93a63d9ed4f8aa 100644 --- a/ios/clean/chrome/browser/ui/dialogs/unavailable_feature_dialogs/unavailable_feature_dialog_mediator_unittest.mm +++ b/ios/clean/chrome/browser/ui/dialogs/unavailable_feature_dialogs/unavailable_feature_dialog_mediator_unittest.mm @@ -9,15 +9,18 @@ #import "ios/clean/chrome/browser/ui/dialogs/dialog_mediator+subclassing.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using UnavailableFeatureDialogMediatorTest = PlatformTest; + // Tests that an UnavailableFeatureDialogMediator correctly uses the feature // name as the message and has one OK button. -TEST(UnavailableFeatureDialogMediator, Simple) { +TEST_F(UnavailableFeatureDialogMediatorTest, Simple) { NSString* kFeatureName = @"Feature Name"; DialogMediator* mediator = [[UnavailableFeatureDialogMediator alloc] initWithFeatureName:kFeatureName]; diff --git a/ios/clean/chrome/browser/ui/root/root_coordinator_unittest.mm b/ios/clean/chrome/browser/ui/root/root_coordinator_unittest.mm index db6a92a38204bd..83f7a7cf520a2a 100644 --- a/ios/clean/chrome/browser/ui/root/root_coordinator_unittest.mm +++ b/ios/clean/chrome/browser/ui/root/root_coordinator_unittest.mm @@ -6,6 +6,7 @@ #import "ios/clean/chrome/browser/url_opening.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,8 +14,10 @@ namespace { +using RootCoordinatorTest = PlatformTest; + // Tests that RootCoordinator conforms to the URLOpening protocol. -TEST(RootCoordinatorTest, TestConformsToURLOpening) { +TEST_F(RootCoordinatorTest, TestConformsToURLOpening) { EXPECT_TRUE([RootCoordinator conformsToProtocol:@protocol(URLOpening)]); } diff --git a/ios/clean/chrome/browser/ui/transitions/animators/swap_from_above_animator_unittest.mm b/ios/clean/chrome/browser/ui/transitions/animators/swap_from_above_animator_unittest.mm index 60aa8a0279ba93..50b6495f978f8c 100644 --- a/ios/clean/chrome/browser/ui/transitions/animators/swap_from_above_animator_unittest.mm +++ b/ios/clean/chrome/browser/ui/transitions/animators/swap_from_above_animator_unittest.mm @@ -7,12 +7,15 @@ #import "base/test/ios/wait_util.h" #import "ios/clean/chrome/browser/ui/transitions/animators/test_transition_context.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif -TEST(SwapFromAboveAnimatorTest, AnimationCallsCompleteTransitionOnContext) { +using SwapFromAboveAnimatorTest = PlatformTest; + +TEST_F(SwapFromAboveAnimatorTest, AnimationCallsCompleteTransitionOnContext) { SwapFromAboveAnimator* animator = [[SwapFromAboveAnimator alloc] init]; TestTransitionContext* context = [[TestTransitionContext alloc] init]; diff --git a/ios/clean/chrome/browser/ui/transitions/containment_transition_context_unittest.mm b/ios/clean/chrome/browser/ui/transitions/containment_transition_context_unittest.mm index 3e901c5ec2e81f..0337f41b22215a 100644 --- a/ios/clean/chrome/browser/ui/transitions/containment_transition_context_unittest.mm +++ b/ios/clean/chrome/browser/ui/transitions/containment_transition_context_unittest.mm @@ -5,6 +5,7 @@ #import "ios/clean/chrome/browser/ui/transitions/containment_transition_context.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -77,9 +78,11 @@ - (void)didMoveToParentViewController:(UIViewController*)parent { @end +using ContainmentTransitionContextTest = PlatformTest; + // Tests that the view controllers are properly returned by the context after // initialization. -TEST(ContainmentTransitionContextTest, InitializationChildViewControllers) { +TEST_F(ContainmentTransitionContextTest, InitializationChildViewControllers) { UIViewController* fromViewController = [[UIViewController alloc] init]; UIViewController* toViewController = [[UIViewController alloc] init]; UIViewController* parentViewController = [[UIViewController alloc] init]; @@ -108,7 +111,7 @@ - (void)didMoveToParentViewController:(UIViewController*)parent { // Tests that the container view is properly returned by the context after // initialization. -TEST(ContainmentTransitionContextTest, InitializationContainerView) { +TEST_F(ContainmentTransitionContextTest, InitializationContainerView) { UIView* containerView = [[UIView alloc] init]; ContainmentTransitionContext* context = [[ContainmentTransitionContext alloc] initWithFromViewController:nil @@ -122,7 +125,7 @@ - (void)didMoveToParentViewController:(UIViewController*)parent { // Tests that the view controllers receive the appropriate calls to perform a // containment transition when prepareTransitionWithAnimator: and // completeTransition: are called. -TEST(ContainmentTransitionContextTest, PrepareAndTransition) { +TEST_F(ContainmentTransitionContextTest, PrepareAndTransition) { TestViewController* fromViewController = [[TestViewController alloc] init]; TestViewController* toViewController = [[TestViewController alloc] init]; UIViewController* parentViewController = [[UIViewController alloc] init]; @@ -171,7 +174,7 @@ - (void)didMoveToParentViewController:(UIViewController*)parent { EXPECT_EQ(parentViewController, toViewController.didMoveToParentArgument); } -TEST(ContainmentTransitionContextTest, CompletionBlockCalledOnCompletion) { +TEST_F(ContainmentTransitionContextTest, CompletionBlockCalledOnCompletion) { __block NSUInteger count = 0; __block BOOL didComplete = NO; ContainmentTransitionContext* context = [[ContainmentTransitionContext alloc] @@ -188,7 +191,7 @@ - (void)didMoveToParentViewController:(UIViewController*)parent { EXPECT_EQ(YES, didComplete); } -TEST(ContainmentTransitionContextTest, CompletionBlockCalledOnCancellation) { +TEST_F(ContainmentTransitionContextTest, CompletionBlockCalledOnCancellation) { __block NSUInteger count = 0; __block BOOL didComplete = NO; ContainmentTransitionContext* context = [[ContainmentTransitionContext alloc] @@ -205,7 +208,7 @@ - (void)didMoveToParentViewController:(UIViewController*)parent { EXPECT_EQ(NO, didComplete); } -TEST(ContainmentTransitionContextTest, AnimationEndedCalledOnCompletion) { +TEST_F(ContainmentTransitionContextTest, AnimationEndedCalledOnCompletion) { ContainmentTransitionContext* context = [[ContainmentTransitionContext alloc] initWithFromViewController:nil toViewController:nil @@ -229,7 +232,7 @@ - (void)didMoveToParentViewController:(UIViewController*)parent { EXPECT_FALSE(animator.animateTransitionCalled); } -TEST(ContainmentTransitionContextTest, AnimationEndedCalledOnCancellation) { +TEST_F(ContainmentTransitionContextTest, AnimationEndedCalledOnCancellation) { ContainmentTransitionContext* context = [[ContainmentTransitionContext alloc] initWithFromViewController:nil toViewController:nil diff --git a/ios/net/cookies/cookie_cache_unittest.cc b/ios/net/cookies/cookie_cache_unittest.cc index e1a8533a37a94a..366588318874a2 100644 --- a/ios/net/cookies/cookie_cache_unittest.cc +++ b/ios/net/cookies/cookie_cache_unittest.cc @@ -7,6 +7,7 @@ #include "net/cookies/canonical_cookie.h" #include "net/cookies/cookie_constants.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" namespace net { @@ -25,7 +26,9 @@ CanonicalCookie MakeCookie(const GURL& url, } // namespace -TEST(CookieCacheTest, UpdateAddsCookieAllowsnullptr) { +using CookieCacheTest = PlatformTest; + +TEST_F(CookieCacheTest, UpdateAddsCookieAllowsnullptr) { CookieCache cache; const GURL test_url("http://www.google.com"); std::vector cookies; @@ -34,7 +37,7 @@ TEST(CookieCacheTest, UpdateAddsCookieAllowsnullptr) { EXPECT_FALSE(cache.Update(test_url, "abc", cookies, nullptr, nullptr)); } -TEST(CookieCacheTest, UpdateAddsCookie) { +TEST_F(CookieCacheTest, UpdateAddsCookie) { CookieCache cache; const GURL test_url("http://www.google.com"); std::vector cookies; @@ -55,7 +58,7 @@ TEST(CookieCacheTest, UpdateAddsCookie) { EXPECT_TRUE(changed.empty()); } -TEST(CookieCacheTest, UpdateAddsDistinctCookie) { +TEST_F(CookieCacheTest, UpdateAddsDistinctCookie) { CookieCache cache; const GURL test_url("http://www.google.com"); const GURL test_url_path("http://www.google.com/foo"); @@ -87,7 +90,7 @@ TEST(CookieCacheTest, UpdateAddsDistinctCookie) { EXPECT_EQ(1U, changed.size()); } -TEST(CookieCacheTest, UpdateValueChanged) { +TEST_F(CookieCacheTest, UpdateValueChanged) { CookieCache cache; const GURL test_url("http://www.google.com"); std::vector cookies; @@ -108,7 +111,7 @@ TEST(CookieCacheTest, UpdateValueChanged) { EXPECT_EQ("ghi", changed[0].Value()); } -TEST(CookieCacheTest, UpdateDeletedCookie) { +TEST_F(CookieCacheTest, UpdateDeletedCookie) { CookieCache cache; const GURL test_url("http://www.google.com"); std::vector cookies; @@ -123,7 +126,7 @@ TEST(CookieCacheTest, UpdateDeletedCookie) { EXPECT_TRUE(changed.empty()); } -TEST(CookieCacheTest, UpdatePathChanged) { +TEST_F(CookieCacheTest, UpdatePathChanged) { CookieCache cache; const GURL test_url("http://www.google.com"); const GURL test_url_path("http://www.google.com/foo"); @@ -139,7 +142,7 @@ TEST(CookieCacheTest, UpdatePathChanged) { EXPECT_EQ(1U, changed.size()); } -TEST(CookieCacheTest, MultipleDomains) { +TEST_F(CookieCacheTest, MultipleDomains) { CookieCache cache; const GURL test_url_a("http://www.google.com"); const GURL test_url_b("http://test.google.com"); @@ -152,7 +155,7 @@ TEST(CookieCacheTest, MultipleDomains) { EXPECT_FALSE(cache.Update(test_url_b, "abc", cookies, nullptr, nullptr)); } -TEST(CookieCacheTest, MultipleNames) { +TEST_F(CookieCacheTest, MultipleNames) { CookieCache cache; const GURL cookieurl("http://google.com"); std::vector cookies; diff --git a/ios/net/cookies/cookie_creation_time_manager_unittest.mm b/ios/net/cookies/cookie_creation_time_manager_unittest.mm index 9b1f45779fe036..0fbeed163e8a73 100644 --- a/ios/net/cookies/cookie_creation_time_manager_unittest.mm +++ b/ios/net/cookies/cookie_creation_time_manager_unittest.mm @@ -10,6 +10,7 @@ #include "base/ios/ios_util.h" #include "base/time/time.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -17,7 +18,7 @@ namespace net { -class CookieCreationTimeManagerTest : public testing::Test { +class CookieCreationTimeManagerTest : public PlatformTest { public: NSHTTPCookie* GetCookie(NSString* cookie_line) { NSArray* cookies = [NSHTTPCookie diff --git a/ios/net/cookies/cookie_store_ios_persistent_unittest.mm b/ios/net/cookies/cookie_store_ios_persistent_unittest.mm index e96579bcf018b9..51b2f497e3ad9f 100644 --- a/ios/net/cookies/cookie_store_ios_persistent_unittest.mm +++ b/ios/net/cookies/cookie_store_ios_persistent_unittest.mm @@ -16,6 +16,7 @@ #import "ios/net/cookies/cookie_store_ios_test_util.h" #include "net/cookies/cookie_store_unittest.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -52,7 +53,7 @@ // Test fixture to exercise net::CookieStoreIOSPersistent created with // TestPersistentCookieStore back-end and not synchronized with // SystemCookieStore. -class CookieStoreIOSPersistentTest : public testing::Test { +class CookieStoreIOSPersistentTest : public PlatformTest { public: CookieStoreIOSPersistentTest() : kTestCookieURL("http://foo.google.com/bar"), diff --git a/ios/net/cookies/cookie_store_ios_unittest.mm b/ios/net/cookies/cookie_store_ios_unittest.mm index 39daf4c1b31a2f..b4f9daefd88e20 100644 --- a/ios/net/cookies/cookie_store_ios_unittest.mm +++ b/ios/net/cookies/cookie_store_ios_unittest.mm @@ -21,6 +21,7 @@ #import "net/base/mac/url_conversions.h" #include "net/cookies/cookie_store_unittest.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -97,7 +98,7 @@ void IgnoreString(const std::string& ignored) { // Test fixture to exercise net::CookieStoreIOS created without backend and // synchronized with |[NSHTTPCookieStorage sharedHTTPCookieStorage]|. -class CookieStoreIOSTest : public testing::Test { +class CookieStoreIOSTest : public PlatformTest { public: CookieStoreIOSTest() : kTestCookieURLFooBar("http://foo.google.com/bar"), @@ -231,8 +232,7 @@ void DeleteSystemCookie(const GURL& gurl, const std::string& name) { EXPECT_EQ(1U, cookies_changed_.size()); } -TEST(CookieStoreIOS, GetAllCookiesForURLAsync) { - base::MessageLoop loop; +TEST_F(CookieStoreIOSTest, GetAllCookiesForURLAsync) { const GURL kTestCookieURLFooBar("http://foo.google.com/bar"); ScopedTestingCookieStoreIOSClient scoped_cookie_store_ios_client( base::MakeUnique()); diff --git a/ios/net/cookies/system_cookie_util_unittest.mm b/ios/net/cookies/system_cookie_util_unittest.mm index ab9bf3de767e30..8e4f2cf9797649 100644 --- a/ios/net/cookies/system_cookie_util_unittest.mm +++ b/ios/net/cookies/system_cookie_util_unittest.mm @@ -11,6 +11,7 @@ #include "net/cookies/cookie_constants.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -60,7 +61,9 @@ void CheckSystemCookie(const base::Time& expires, bool secure, bool httponly) { } // namespace -TEST(CookieUtil, CanonicalCookieFromSystemCookie) { +using CookieUtil = PlatformTest; + +TEST_F(CookieUtil, CanonicalCookieFromSystemCookie) { base::Time creation_time = base::Time::Now(); base::Time expire_date = creation_time + base::TimeDelta::FromHours(2); NSDate* system_expire_date = @@ -106,7 +109,7 @@ void CheckSystemCookie(const base::Time& expires, bool secure, bool httponly) { EXPECT_TRUE(chrome_cookie.IsSecure()); } -TEST(CookieUtil, SystemCookieFromCanonicalCookie) { +TEST_F(CookieUtil, SystemCookieFromCanonicalCookie) { base::Time expire_date = base::Time::Now() + base::TimeDelta::FromHours(2); // Test various combinations of session, secure and httponly attributes. @@ -116,7 +119,7 @@ void CheckSystemCookie(const base::Time& expires, bool secure, bool httponly) { CheckSystemCookie(base::Time(), true, true); } -TEST(CookieUtil, SystemCookieFromBadCanonicalCookie) { +TEST_F(CookieUtil, SystemCookieFromBadCanonicalCookie) { // Generate a bad canonical cookie (value is invalid utf8). net::CanonicalCookie bad_canonical_cookie( kCookieName, kCookieValueInvalidUtf8, kCookieDomain, kCookiePath, diff --git a/ios/net/http_response_headers_util_unittest.mm b/ios/net/http_response_headers_util_unittest.mm index ae64284c9319e5..07b3b9b8cdb4eb 100644 --- a/ios/net/http_response_headers_util_unittest.mm +++ b/ios/net/http_response_headers_util_unittest.mm @@ -11,6 +11,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/sys_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -39,9 +40,11 @@ bool AreHeadersEqual(NSHTTPURLResponse* http_response, return all_headers_present; } +using HttpResponseHeadersUtilTest = PlatformTest; + // Tests that HttpResponseHeaders created from NSHTTPURLResponses successfully // copy over the status code and the header names and values. -TEST(HttpResponseHeadersUtilTest, CreateHeadersFromNSHTTPURLResponse) { +TEST_F(HttpResponseHeadersUtilTest, CreateHeadersFromNSHTTPURLResponse) { NSHTTPURLResponse* http_response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@"test.com"] statusCode:200 diff --git a/ios/net/nsurlrequest_util_unittest.mm b/ios/net/nsurlrequest_util_unittest.mm index fcd848ff722df5..0cd7635e3dbf20 100644 --- a/ios/net/nsurlrequest_util_unittest.mm +++ b/ios/net/nsurlrequest_util_unittest.mm @@ -5,6 +5,7 @@ #include "ios/net/nsurlrequest_util.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -12,9 +13,11 @@ namespace { +using NSURLRequestUtilTest = PlatformTest; + // Tests that FormatUrlRequestForLogging outputs the string in the form: // request: request.mainDocURL:. -TEST(NSURLRequestUtilTest, FormatUrlRequestForLogging) { +TEST_F(NSURLRequestUtilTest, FormatUrlRequestForLogging) { NSMutableURLRequest* request = [[NSMutableURLRequest alloc] init]; request.URL = [NSURL URLWithString:@"http://www.google.com"]; request.mainDocumentURL = [NSURL URLWithString:@"http://www.google1.com"]; diff --git a/ios/net/protocol_handler_util_unittest.mm b/ios/net/protocol_handler_util_unittest.mm index ff386ec47722ba..10992f0ac7b997 100644 --- a/ios/net/protocol_handler_util_unittest.mm +++ b/ios/net/protocol_handler_util_unittest.mm @@ -24,6 +24,7 @@ #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -108,7 +109,7 @@ void GetResponseInfo(HttpResponseInfo* info) override { } }; -class ProtocolHandlerUtilTest : public testing::Test, +class ProtocolHandlerUtilTest : public PlatformTest, public URLRequest::Delegate { public: ProtocolHandlerUtilTest() : request_context_(new TestURLRequestContext) { diff --git a/ios/net/url_scheme_util_unittest.mm b/ios/net/url_scheme_util_unittest.mm index b91a0de14bfe86..7a96d9c429b59c 100644 --- a/ios/net/url_scheme_util_unittest.mm +++ b/ios/net/url_scheme_util_unittest.mm @@ -8,6 +8,7 @@ #include "base/macros.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -24,7 +25,9 @@ "chrome://settings", }; -TEST(URLSchemeUtilTest, NSURLHasDataScheme) { +using URLSchemeUtilTest = PlatformTest; + +TEST_F(URLSchemeUtilTest, NSURLHasDataScheme) { for (unsigned int i = 0; i < arraysize(kSchemeTestData); ++i) { const char* url = kSchemeTestData[i]; bool nsurl_result = UrlHasDataScheme( diff --git a/ios/web/browser_state_unittest.cc b/ios/web/browser_state_unittest.cc index 435dc40f8dd036..06a25b092eb5ed 100644 --- a/ios/web/browser_state_unittest.cc +++ b/ios/web/browser_state_unittest.cc @@ -7,6 +7,7 @@ #include "base/supports_user_data.h" #include "ios/web/public/test/fakes/test_browser_state.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" namespace { class TestSupportsUserData : public base::SupportsUserData { @@ -16,18 +17,20 @@ class TestSupportsUserData : public base::SupportsUserData { }; } // namespace -TEST(BrowserStateTest, FromSupportsUserData_NullPointer) { +using BrowserStateTest = PlatformTest; + +TEST_F(BrowserStateTest, FromSupportsUserData_NullPointer) { DCHECK_EQ(static_cast(nullptr), web::BrowserState::FromSupportsUserData(nullptr)); } -TEST(BrowserStateTest, FromSupportsUserData_NonBrowserState) { +TEST_F(BrowserStateTest, FromSupportsUserData_NonBrowserState) { TestSupportsUserData supports_user_data; DCHECK_EQ(static_cast(nullptr), web::BrowserState::FromSupportsUserData(&supports_user_data)); } -TEST(BrowserStateTest, FromSupportsUserData) { +TEST_F(BrowserStateTest, FromSupportsUserData) { web::TestBrowserState browser_state; DCHECK_EQ(&browser_state, web::BrowserState::FromSupportsUserData(&browser_state)); diff --git a/ios/web/history_state_util_unittest.mm b/ios/web/history_state_util_unittest.mm index 3321b6e11b2693..e5de52a4a0791f 100644 --- a/ios/web/history_state_util_unittest.mm +++ b/ios/web/history_state_util_unittest.mm @@ -9,6 +9,7 @@ #include "base/macros.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -23,7 +24,7 @@ std::string expectedUrl; }; -class HistoryStateUtilTest : public ::testing::Test { +class HistoryStateUtilTest : public PlatformTest { protected: static const struct TestEntry tests_[]; }; diff --git a/ios/web/net/cert_policy_unittest.cc b/ios/web/net/cert_policy_unittest.cc index 1f0bbeefea09d2..e8d7308c312b5c 100644 --- a/ios/web/net/cert_policy_unittest.cc +++ b/ios/web/net/cert_policy_unittest.cc @@ -8,10 +8,13 @@ #include "net/cert/x509_certificate.h" #include "net/test/test_certificate_data.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" namespace web { -TEST(CertPolicyTest, Policy) { +using CertPolicyTest = PlatformTest; + +TEST_F(CertPolicyTest, Policy) { scoped_refptr google_cert( net::X509Certificate::CreateFromBytes( reinterpret_cast(google_der), sizeof(google_der))); diff --git a/ios/web/net/request_group_util_unittest.mm b/ios/web/net/request_group_util_unittest.mm index d05953d103d28d..dd25c6e57a4d45 100644 --- a/ios/web/net/request_group_util_unittest.mm +++ b/ios/web/net/request_group_util_unittest.mm @@ -8,14 +8,17 @@ #include #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using RequestGroupUtilTest = PlatformTest; + // Checks that all newly generated groupID are unique and that there are no // duplicates. -TEST(RequestGroupUtilTest, RequestGroupID) { +TEST_F(RequestGroupUtilTest, RequestGroupID) { NSMutableSet* set = [[NSMutableSet alloc] init]; const size_t kGenerated = 2000; for (size_t i = 0; i < kGenerated; ++i) @@ -25,7 +28,7 @@ // Tests that the ExtractRequestGroupIDFromUserAgent function behaves as // intended. -TEST(RequestGroupUtilTest, ExtractRequestGroupIDFromUserAgent) { +TEST_F(RequestGroupUtilTest, ExtractRequestGroupIDFromUserAgent) { EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(nil)); EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent( @"Lynx/2.8.1pre.9 libwww-FM/2.14")); diff --git a/ios/web/net/web_http_protocol_handler_delegate_unittest.mm b/ios/web/net/web_http_protocol_handler_delegate_unittest.mm index 251bc481b8b155..33e2ad46fb584e 100644 --- a/ios/web/net/web_http_protocol_handler_delegate_unittest.mm +++ b/ios/web/net/web_http_protocol_handler_delegate_unittest.mm @@ -16,6 +16,7 @@ #import "ios/web/public/web_client.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -50,7 +51,7 @@ bool IsAppSpecificURL(const GURL& url) const override { } }; -class WebHTTPProtocolHandlerDelegateTest : public testing::Test { +class WebHTTPProtocolHandlerDelegateTest : public PlatformTest { public: WebHTTPProtocolHandlerDelegateTest() : context_getter_(new net::TestURLRequestContextGetter( diff --git a/ios/web/payments/payment_request_unittest.cc b/ios/web/payments/payment_request_unittest.cc index 8ebaac6b58d6f1..6a5138b1002db5 100644 --- a/ios/web/payments/payment_request_unittest.cc +++ b/ios/web/payments/payment_request_unittest.cc @@ -11,13 +11,16 @@ #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" namespace web { // PaymentRequest parsing tests. +using PaymentRequestTest = PlatformTest; + // Tests that populating a PaymentRequest from an empty dictionary fails. -TEST(PaymentRequestTest, ParsingEmptyRequestDictionaryFails) { +TEST_F(PaymentRequestTest, ParsingEmptyRequestDictionaryFails) { PaymentRequest output_request; base::DictionaryValue request_dict; EXPECT_FALSE(output_request.FromDictionaryValue(request_dict)); @@ -25,7 +28,7 @@ TEST(PaymentRequestTest, ParsingEmptyRequestDictionaryFails) { // Tests that populating a PaymentRequest from a dictionary without all // required values fails. -TEST(PaymentRequestTest, ParsingPartiallyPopulatedRequestDictionaryFails) { +TEST_F(PaymentRequestTest, ParsingPartiallyPopulatedRequestDictionaryFails) { PaymentRequest expected_request; PaymentRequest output_request; base::DictionaryValue request_dict; @@ -58,7 +61,7 @@ TEST(PaymentRequestTest, ParsingPartiallyPopulatedRequestDictionaryFails) { // Tests that populating a PaymentRequest from a dictionary with all required // elements succeeds and produces the expected result. -TEST(PaymentRequestTest, ParsingFullyPopulatedRequestDictionarySucceeds) { +TEST_F(PaymentRequestTest, ParsingFullyPopulatedRequestDictionarySucceeds) { PaymentRequest expected_request; PaymentRequest output_request; base::DictionaryValue request_dict; @@ -127,7 +130,7 @@ TEST(PaymentRequestTest, ParsingFullyPopulatedRequestDictionarySucceeds) { // PaymentRequest serialization tests. // Tests that serializing a default PaymentResponse yields the expected result. -TEST(PaymentRequestTest, EmptyResponseDictionary) { +TEST_F(PaymentRequestTest, EmptyResponseDictionary) { base::DictionaryValue expected_value; expected_value.SetString("requestId", ""); @@ -146,7 +149,7 @@ TEST(PaymentRequestTest, EmptyResponseDictionary) { // Tests that serializing a populated PaymentResponse yields the expected // result. -TEST(PaymentRequestTest, PopulatedResponseDictionary) { +TEST_F(PaymentRequestTest, PopulatedResponseDictionary) { base::DictionaryValue expected_value; std::unique_ptr details(new base::DictionaryValue); @@ -226,7 +229,7 @@ TEST(PaymentRequestTest, PopulatedResponseDictionary) { // Tests that two payment options objects are not equal if their property values // differ and equal otherwise. -TEST(PaymentRequestTest, PaymentOptionsEquality) { +TEST_F(PaymentRequestTest, PaymentOptionsEquality) { PaymentOptions options1; PaymentOptions options2; EXPECT_EQ(options1, options2); @@ -265,7 +268,7 @@ TEST(PaymentRequestTest, PaymentOptionsEquality) { // differ or one is missing a value present in the other, and equal otherwise. // Doesn't test all properties of child objects, relying instead on their // respective tests. -TEST(PaymentRequestTest, PaymentRequestEquality) { +TEST_F(PaymentRequestTest, PaymentRequestEquality) { PaymentRequest request1; PaymentRequest request2; EXPECT_EQ(request1, request2); @@ -332,7 +335,7 @@ TEST(PaymentRequestTest, PaymentRequestEquality) { // values differ or one is missing a value present in the other, and equal // otherwise. Doesn't test all properties of child objects, relying instead on // their respective tests. -TEST(PaymentRequestTest, PaymentResponseEquality) { +TEST_F(PaymentRequestTest, PaymentResponseEquality) { PaymentResponse response1; PaymentResponse response2; EXPECT_EQ(response1, response2); diff --git a/ios/web/public/crw_session_certificate_policy_cache_storage_unittest.mm b/ios/web/public/crw_session_certificate_policy_cache_storage_unittest.mm index 696ba5f617d17a..d973956650595d 100644 --- a/ios/web/public/crw_session_certificate_policy_cache_storage_unittest.mm +++ b/ios/web/public/crw_session_certificate_policy_cache_storage_unittest.mm @@ -73,9 +73,11 @@ bool CacheStoragesAreEqual( EXPECT_TRUE(CacheStoragesAreEqual(cache_storage_.get(), decoded)); } +using CRWSessionCertificateStorageTest = PlatformTest; + // Tests that unarchiving a CRWSessionCertificateStorage returns nil if the // certificate data does not correctly decode to a certificate. -TEST(CRWSessionCertificateStorageTest, InvalidCertData) { +TEST_F(CRWSessionCertificateStorageTest, InvalidCertData) { NSMutableData* data = [[NSMutableData alloc] init]; NSKeyedArchiver* archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; diff --git a/ios/web/public/origin_util_unittest.mm b/ios/web/public/origin_util_unittest.mm index ec49ff11b30f36..79be9f505bb624 100644 --- a/ios/web/public/origin_util_unittest.mm +++ b/ios/web/public/origin_util_unittest.mm @@ -7,6 +7,7 @@ #import #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -29,8 +30,10 @@ @implementation WKSecurityOriginStub namespace web { +using OriginUtilTest = PlatformTest; + // Tests calling GURLOriginWithWKSecurityOrigin with nil. -TEST(OriginUtilTest, GURLOriginWithNilWKSecurityOrigin) { +TEST_F(OriginUtilTest, GURLOriginWithNilWKSecurityOrigin) { GURL url(GURLOriginWithWKSecurityOrigin(nil)); EXPECT_FALSE(url.is_valid()); @@ -38,7 +41,7 @@ @implementation WKSecurityOriginStub } // Tests calling GURLOriginWithWKSecurityOrigin with valid origin. -TEST(OriginUtilTest, GURLOriginWithValidWKSecurityOrigin) { +TEST_F(OriginUtilTest, GURLOriginWithValidWKSecurityOrigin) { WKSecurityOriginStub* origin = [[WKSecurityOriginStub alloc] init]; [origin setProtocol:@"http"]; [origin setHost:@"chromium.org"]; diff --git a/ios/web/public/referrer_util_unittest.cc b/ios/web/public/referrer_util_unittest.cc index 9da6fae1e97af1..4661c09552ce09 100644 --- a/ios/web/public/referrer_util_unittest.cc +++ b/ios/web/public/referrer_util_unittest.cc @@ -7,6 +7,7 @@ #include "base/macros.h" #include "ios/web/public/referrer.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #include "url/gurl.h" namespace { @@ -23,9 +24,11 @@ const char* const kTestUrls[] = { namespace web { +using ReferrerUtilTest = PlatformTest; + // Tests that no matter what the transition and policy, the result is always // stripped of things that should not be in a referrer (e.g., passwords). -TEST(ReferrerUtilTest, ReferrerSanitization) { +TEST_F(ReferrerUtilTest, ReferrerSanitization) { for (unsigned int source = 0; source < arraysize(kTestUrls); ++source) { for (unsigned int dest = 0; dest < arraysize(kTestUrls); ++dest) { for (unsigned int policy = 0; policy <= ReferrerPolicyLast; ++policy) { @@ -41,7 +44,7 @@ TEST(ReferrerUtilTest, ReferrerSanitization) { } // Tests that the Always policy works as expected. -TEST(ReferrerUtilTest, AlwaysPolicy) { +TEST_F(ReferrerUtilTest, AlwaysPolicy) { for (unsigned int source = 0; source < arraysize(kTestUrls); ++source) { for (unsigned int dest = 1; dest < arraysize(kTestUrls); ++dest) { GURL source_url(kTestUrls[source]); @@ -57,7 +60,7 @@ TEST(ReferrerUtilTest, AlwaysPolicy) { // Tests that the Default policy works as expected, and matches // NoReferrerWhenDowngrade. -TEST(ReferrerUtilTest, DefaultPolicy) { +TEST_F(ReferrerUtilTest, DefaultPolicy) { for (unsigned int source = 0; source < arraysize(kTestUrls); ++source) { for (unsigned int dest = 1; dest < arraysize(kTestUrls); ++dest) { GURL source_url(kTestUrls[source]); @@ -80,7 +83,7 @@ TEST(ReferrerUtilTest, DefaultPolicy) { } // Tests that the Never policy works as expected. -TEST(ReferrerUtilTest, NeverPolicy) { +TEST_F(ReferrerUtilTest, NeverPolicy) { for (unsigned int source = 0; source < arraysize(kTestUrls); ++source) { for (unsigned int dest = 1; dest < arraysize(kTestUrls); ++dest) { GURL source_url(kTestUrls[source]); @@ -95,7 +98,7 @@ TEST(ReferrerUtilTest, NeverPolicy) { } // Tests that the Origin policy works as expected. -TEST(ReferrerUtilTest, OriginPolicy) { +TEST_F(ReferrerUtilTest, OriginPolicy) { for (unsigned int source = 0; source < arraysize(kTestUrls); ++source) { for (unsigned int dest = 1; dest < arraysize(kTestUrls); ++dest) { GURL source_url(kTestUrls[source]); @@ -110,7 +113,7 @@ TEST(ReferrerUtilTest, OriginPolicy) { } // Tests that the OriginWhenCrossOrigin policy works as expected. -TEST(ReferrerUtilTest, OriginWhenCrossOriginPolicy) { +TEST_F(ReferrerUtilTest, OriginWhenCrossOriginPolicy) { for (unsigned int source = 0; source < arraysize(kTestUrls); ++source) { for (unsigned int dest = 1; dest < arraysize(kTestUrls); ++dest) { GURL source_url(kTestUrls[source]); @@ -129,7 +132,7 @@ TEST(ReferrerUtilTest, OriginWhenCrossOriginPolicy) { } // Tests that the same-origin policy works as expected. -TEST(ReferrerUtilTest, SameOriginPolicy) { +TEST_F(ReferrerUtilTest, SameOriginPolicy) { for (unsigned int source = 0; source < arraysize(kTestUrls); ++source) { for (unsigned int dest = 1; dest < arraysize(kTestUrls); ++dest) { GURL source_url(kTestUrls[source]); @@ -147,7 +150,7 @@ TEST(ReferrerUtilTest, SameOriginPolicy) { } // Tests that the strict-origin policy works as expected. -TEST(ReferrerUtilTest, StrictOriginPolicy) { +TEST_F(ReferrerUtilTest, StrictOriginPolicy) { for (unsigned int source = 0; source < arraysize(kTestUrls); ++source) { for (unsigned int dest = 1; dest < arraysize(kTestUrls); ++dest) { GURL source_url(kTestUrls[source]); @@ -166,7 +169,7 @@ TEST(ReferrerUtilTest, StrictOriginPolicy) { } // Tests that the strict-origin-when-cross-origin policy works as expected. -TEST(ReferrerUtilTest, StrictOriginWhenCrossOriginPolicy) { +TEST_F(ReferrerUtilTest, StrictOriginWhenCrossOriginPolicy) { for (unsigned int source = 0; source < arraysize(kTestUrls); ++source) { for (unsigned int dest = 1; dest < arraysize(kTestUrls); ++dest) { GURL source_url(kTestUrls[source]); @@ -188,7 +191,7 @@ TEST(ReferrerUtilTest, StrictOriginWhenCrossOriginPolicy) { } // Tests that PolicyForNavigation gives the right values. -TEST(ReferrerUtilTest, PolicyForNavigation) { +TEST_F(ReferrerUtilTest, PolicyForNavigation) { // The request and destination URLs are unused in the current implementation, // so use a dummy value. GURL dummy_url; @@ -239,7 +242,7 @@ TEST(ReferrerUtilTest, PolicyForNavigation) { // Tests that all the strings corresponding to web::ReferrerPolicy values are // correctly handled. -TEST(ReferrerUtilTest, PolicyFromString) { +TEST_F(ReferrerUtilTest, PolicyFromString) { // The ordering here must match web::ReferrerPolicy; this makes the test // simpler, at the cost of needing to re-order if the enum is re-ordered. const char* const kPolicyStrings[] = { diff --git a/ios/web/public/user_agent_unittest.mm b/ios/web/public/user_agent_unittest.mm index 3a1835d3bbc195..615ff80691fd61 100644 --- a/ios/web/public/user_agent_unittest.mm +++ b/ios/web/public/user_agent_unittest.mm @@ -5,6 +5,7 @@ #import "ios/web/public/user_agent.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -12,8 +13,10 @@ namespace web { +using UserAgentTest = PlatformTest; + // Tests conversions between UserAgentType values and their descriptions -TEST(UserAgentTest, UserAgentTypeDescription) { +TEST_F(UserAgentTest, UserAgentTypeDescription) { const std::string kMobileDescription("MOBILE"); const std::string kDesktopDescription("DESKTOP"); const std::string kNoneDescription("NONE"); diff --git a/ios/web/public/web_state/page_viewport_state_unittest.mm b/ios/web/public/web_state/page_viewport_state_unittest.mm index c2f67695e071ba..53945a028a1c97 100644 --- a/ios/web/public/web_state/page_viewport_state_unittest.mm +++ b/ios/web/public/web_state/page_viewport_state_unittest.mm @@ -6,6 +6,7 @@ #include "base/macros.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -14,8 +15,10 @@ namespace web { +using ViewportLengthTest = PlatformTest; + // Verifies viewport length construction for "device-width" and "device-height". -TEST(ViewportLengthTest, DeviceDimension) { +TEST_F(ViewportLengthTest, DeviceDimension) { ViewportLength device_width(@"device-width"); EXPECT_TRUE(device_width.use_device_length()); EXPECT_TRUE(isnan(device_width.value())); @@ -25,21 +28,23 @@ } // Verifies viewport length construction for a hardcoded length value. -TEST(ViewportLengthTest, HardcodedDimension) { +TEST_F(ViewportLengthTest, HardcodedDimension) { ViewportLength hardcoded_length(@"1024.0"); EXPECT_FALSE(hardcoded_length.use_device_length()); EXPECT_EQ(1024.0, hardcoded_length.value()); } // Tests that malformed strings are handled correctly. -TEST(ViewportLengthTest, MalformedInput) { +TEST_F(ViewportLengthTest, MalformedInput) { ViewportLength length(@"malformed input"); EXPECT_FALSE(length.use_device_length()); EXPECT_TRUE(isnan(length.value())); } +using PageViewportStateTest = PlatformTest; + // Tests that a well-formed viewport tag is successfully parsed. -TEST(PageViewportStateTest, ValidInputParsing) { +TEST_F(PageViewportStateTest, ValidInputParsing) { NSString* const kViewportContent = @"width=device-width, initial-scale=1.0, minimum-scale=1.0," "maximum-scale=5.0,user-scalable=no"; @@ -53,7 +58,7 @@ } // Tests that malformed strings are handled correctly. -TEST(PageViewportStateTest, MalformedInput) { +TEST_F(PageViewportStateTest, MalformedInput) { NSString* const kViewportContent = @"width=, initial-scale=not a valid value,, maximum-scale = "; PageViewportState state(kViewportContent); @@ -64,7 +69,7 @@ } // Tests parsing of the user-scalable property. -TEST(PageViewportStateTest, UserScalableParsing) { +TEST_F(PageViewportStateTest, UserScalableParsing) { PageViewportState state(@"user-scalable=yes"); EXPECT_TRUE(state.user_scalable()); state = PageViewportState(@"user-scalable=1"); diff --git a/ios/web/service_manager_connection_impl_unittest.cc b/ios/web/service_manager_connection_impl_unittest.cc index f0a605efa02a5a..b768683a891c75 100644 --- a/ios/web/service_manager_connection_impl_unittest.cc +++ b/ios/web/service_manager_connection_impl_unittest.cc @@ -12,6 +12,7 @@ #include "services/service_manager/public/interfaces/constants.mojom.h" #include "services/service_manager/public/interfaces/service_factory.mojom.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" namespace web { namespace { @@ -26,7 +27,9 @@ std::unique_ptr LaunchService( } // namespace -TEST(ServiceManagerConnectionImplTest, ServiceLaunchThreading) { +using ServiceManagerConnectionImplTest = PlatformTest; + +TEST_F(ServiceManagerConnectionImplTest, ServiceLaunchThreading) { TestWebThreadBundle thread_bundle( TestWebThreadBundle::Options::REAL_IO_THREAD); // base::MessageLoop message_loop; diff --git a/ios/web/url_scheme_util_unittest.mm b/ios/web/url_scheme_util_unittest.mm index 46d605a3b1ea21..c1f171b23669f9 100644 --- a/ios/web/url_scheme_util_unittest.mm +++ b/ios/web/url_scheme_util_unittest.mm @@ -7,6 +7,7 @@ #import #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -15,7 +16,9 @@ namespace web { -TEST(URLSchemeUtilTest, UrlHasWebScheme) { +using URLSchemeUtilTest = PlatformTest; + +TEST_F(URLSchemeUtilTest, UrlHasWebScheme) { EXPECT_TRUE(UrlHasWebScheme(GURL("http://foo.com"))); EXPECT_TRUE(UrlHasWebScheme(GURL("https://foo.com"))); EXPECT_TRUE(UrlHasWebScheme(GURL("data:text/html;charset=utf-8,Hello"))); @@ -23,7 +26,7 @@ EXPECT_FALSE(UrlHasWebScheme(GURL("chrome://settings"))); } -TEST(URLSchemeUtilTest, NSURLHasWebScheme) { +TEST_F(URLSchemeUtilTest, NSURLHasWebScheme) { EXPECT_TRUE(UrlHasWebScheme([NSURL URLWithString:@"http://foo.com"])); EXPECT_TRUE(UrlHasWebScheme([NSURL URLWithString:@"https://foo.com"])); EXPECT_TRUE(UrlHasWebScheme( diff --git a/ios/web/url_util_unittest.cc b/ios/web/url_util_unittest.cc index 5dbf63e6be99a6..720c515097e8d0 100644 --- a/ios/web/url_util_unittest.cc +++ b/ios/web/url_util_unittest.cc @@ -5,10 +5,13 @@ #include "ios/web/public/url_util.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" namespace web { -TEST(URLUtilTest, GURLByRemovingRefFromGURL) { +using URLUtilTest = PlatformTest; + +TEST_F(URLUtilTest, GURLByRemovingRefFromGURL) { GURL url("http://foo.com/bar#baz"); EXPECT_EQ(GURL("http://foo.com/bar"), GURLByRemovingRefFromGURL(url)); } diff --git a/ios/web/web_state/page_display_state_unittest.mm b/ios/web/web_state/page_display_state_unittest.mm index 730da6bfb1ca02..726673d9405130 100644 --- a/ios/web/web_state/page_display_state_unittest.mm +++ b/ios/web/web_state/page_display_state_unittest.mm @@ -7,14 +7,17 @@ #include "testing/gtest/include/gtest/gtest.h" #define EXPECT_NAN(value) EXPECT_NE(value, value) +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using PageDisplayStateTest = PlatformTest; + // Tests that the empty constructor creates an invalid PageDisplayState with all // NAN values. -TEST(PageDisplayStateTest, EmptyConstructor) { +TEST_F(PageDisplayStateTest, EmptyConstructor) { web::PageDisplayState state; EXPECT_NAN(state.scroll_state().offset_x()); EXPECT_NAN(state.scroll_state().offset_y()); @@ -26,7 +29,7 @@ // Tests that the constructor with input states correctly populates the display // state. -TEST(PageDisplayStateTest, StatesConstructor) { +TEST_F(PageDisplayStateTest, StatesConstructor) { web::PageScrollState scroll_state(0.0, 1.0); EXPECT_EQ(0.0, scroll_state.offset_x()); EXPECT_EQ(1.0, scroll_state.offset_y()); @@ -48,7 +51,7 @@ } // Tests the constructor with value inputs. -TEST(PageDisplayStateTest, ValuesConstructor) { +TEST_F(PageDisplayStateTest, ValuesConstructor) { web::PageDisplayState state(0.0, 1.0, 1.0, 5.0, 1.0); EXPECT_EQ(0.0, state.scroll_state().offset_x()); EXPECT_EQ(1.0, state.scroll_state().offset_y()); @@ -59,7 +62,7 @@ } // Tests converting between a PageDisplayState, its serialization, and back. -TEST(PageDisplayStateTest, Serialization) { +TEST_F(PageDisplayStateTest, Serialization) { web::PageDisplayState state(0.0, 1.0, 1.0, 5.0, 1.0); web::PageDisplayState new_state(state.GetSerialization()); EXPECT_EQ(state, new_state); diff --git a/ios/web/web_state/session_certificate_policy_cache_storage_builder_unittest.mm b/ios/web/web_state/session_certificate_policy_cache_storage_builder_unittest.mm index ef424419440be1..97141d638442f9 100644 --- a/ios/web/web_state/session_certificate_policy_cache_storage_builder_unittest.mm +++ b/ios/web/web_state/session_certificate_policy_cache_storage_builder_unittest.mm @@ -13,14 +13,17 @@ #include "net/test/test_data_directory.h" #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." #endif +using SessionCertificatePolicyCacheStorageBuilderTest = PlatformTest; + // Tests that creating a CRWSessionCertificateCacheStorage using BuildStorage() // populates the storage with the correct data. -TEST(SessionCertificatePolicyCacheStorageBuilderTest, BuildStorage) { +TEST_F(SessionCertificatePolicyCacheStorageBuilderTest, BuildStorage) { // Create a cache and populate it with an allowed cert. web::TestWebThreadBundle thread_bundle; web::SessionCertificatePolicyCacheImpl cache; @@ -43,8 +46,8 @@ // Tests that creating a SessionCertificatePolicyCache using // BuildSessionCertificatePolicyCache() creates the cache with the correct data. -TEST(SessionCertificatePolicyCacheStorageBuilderTest, - BuildSessionCertificatePolicyCache) { +TEST_F(SessionCertificatePolicyCacheStorageBuilderTest, + BuildSessionCertificatePolicyCache) { // Create the cert cache storage. scoped_refptr cert = net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); diff --git a/ios/web/web_state/ui/crw_web_view_scroll_view_proxy_unittest.mm b/ios/web/web_state/ui/crw_web_view_scroll_view_proxy_unittest.mm index 8aeaebbb26fbc5..a17d1e92e8de82 100644 --- a/ios/web/web_state/ui/crw_web_view_scroll_view_proxy_unittest.mm +++ b/ios/web/web_state/ui/crw_web_view_scroll_view_proxy_unittest.mm @@ -8,6 +8,7 @@ #include "base/compiler_specific.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" #include "third_party/ocmock/gtest_support.h" @@ -17,7 +18,7 @@ namespace { -class CRWWebViewScrollViewProxyTest : public ::testing::Test { +class CRWWebViewScrollViewProxyTest : public PlatformTest { protected: void SetUp() override { mockScrollView_ = [OCMockObject niceMockForClass:[UIScrollView class]]; diff --git a/ios/web/web_state/ui/web_view_js_utils_unittest.mm b/ios/web/web_state/ui/web_view_js_utils_unittest.mm index 42060026ab695c..e379e63c6888f4 100644 --- a/ios/web/web_state/ui/web_view_js_utils_unittest.mm +++ b/ios/web/web_state/ui/web_view_js_utils_unittest.mm @@ -9,6 +9,7 @@ #import "base/mac/bind_objc_block.h" #include "base/values.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -16,13 +17,15 @@ namespace web { +using WebViewJsUtilsTest = PlatformTest; + // Tests that ValueResultFromWKResult converts nil value to nullptr. -TEST(WebViewJsUtilsTest, ValueResultFromUndefinedWKResult) { +TEST_F(WebViewJsUtilsTest, ValueResultFromUndefinedWKResult) { EXPECT_FALSE(ValueResultFromWKResult(nil)); } // Tests that ValueResultFromWKResult converts string to Value::Type::STRING. -TEST(WebViewJsUtilsTest, ValueResultFromStringWKResult) { +TEST_F(WebViewJsUtilsTest, ValueResultFromStringWKResult) { std::unique_ptr value(web::ValueResultFromWKResult(@"test")); EXPECT_TRUE(value); EXPECT_EQ(base::Value::Type::STRING, value->GetType()); @@ -34,7 +37,7 @@ // Tests that ValueResultFromWKResult converts inetger to Value::Type::DOUBLE. // NOTE: WKWebView API returns all numbers as kCFNumberFloat64Type, so there is // no way to tell if the result is integer or double. -TEST(WebViewJsUtilsTest, ValueResultFromIntegerWKResult) { +TEST_F(WebViewJsUtilsTest, ValueResultFromIntegerWKResult) { std::unique_ptr value(web::ValueResultFromWKResult(@1)); EXPECT_TRUE(value); EXPECT_EQ(base::Value::Type::DOUBLE, value->GetType()); @@ -44,7 +47,7 @@ } // Tests that ValueResultFromWKResult converts double to Value::Type::DOUBLE. -TEST(WebViewJsUtilsTest, ValueResultFromDoubleWKResult) { +TEST_F(WebViewJsUtilsTest, ValueResultFromDoubleWKResult) { std::unique_ptr value(web::ValueResultFromWKResult(@3.14)); EXPECT_TRUE(value); EXPECT_EQ(base::Value::Type::DOUBLE, value->GetType()); @@ -54,7 +57,7 @@ } // Tests that ValueResultFromWKResult converts bool to Value::Type::BOOLEAN. -TEST(WebViewJsUtilsTest, ValueResultFromBoolWKResult) { +TEST_F(WebViewJsUtilsTest, ValueResultFromBoolWKResult) { std::unique_ptr value(web::ValueResultFromWKResult(@YES)); EXPECT_TRUE(value); EXPECT_EQ(base::Value::Type::BOOLEAN, value->GetType()); @@ -64,7 +67,7 @@ } // Tests that ValueResultFromWKResult converts null to Value::Type::NONE. -TEST(WebViewJsUtilsTest, ValueResultFromNullWKResult) { +TEST_F(WebViewJsUtilsTest, ValueResultFromNullWKResult) { std::unique_ptr value( web::ValueResultFromWKResult([NSNull null])); EXPECT_TRUE(value); @@ -73,7 +76,7 @@ // Tests that ValueResultFromWKResult converts NSDictionaries to properly // initialized base::DictionaryValue. -TEST(WebViewJsUtilsTest, ValueResultFromDictionaryWKResult) { +TEST_F(WebViewJsUtilsTest, ValueResultFromDictionaryWKResult) { NSDictionary* test_dictionary = @{ @"Key1" : @"Value1", @"Key2" : @{@"Key3" : @42} }; @@ -99,7 +102,7 @@ // Tests that ValueResultFromWKResult converts NSArray to properly // initialized base::ListValue. -TEST(WebViewJsUtilsTest, ValueResultFromArrayWKResult) { +TEST_F(WebViewJsUtilsTest, ValueResultFromArrayWKResult) { NSArray* test_array = @[ @"Value1", @[ @YES ], @42 ]; std::unique_ptr value(web::ValueResultFromWKResult(test_array)); @@ -124,7 +127,7 @@ } // Tests that an NSDictionary with a cycle does not cause infinite recursion. -TEST(WebViewJsUtilsTest, ValueResultFromDictionaryWithDepthCheckWKResult) { +TEST_F(WebViewJsUtilsTest, ValueResultFromDictionaryWithDepthCheckWKResult) { // Create a dictionary with a cycle. NSMutableDictionary* test_dictionary = [NSMutableDictionary dictionaryWithCapacity:1]; @@ -162,7 +165,7 @@ } // Tests that an NSArray with a cycle does not cause infinite recursion. -TEST(WebViewJsUtilsTest, ValueResultFromArrayWithDepthCheckWKResult) { +TEST_F(WebViewJsUtilsTest, ValueResultFromArrayWithDepthCheckWKResult) { // Create an array with a cycle. NSMutableArray* test_array = [NSMutableArray arrayWithCapacity:1]; NSMutableArray* test_array_2 = [NSMutableArray arrayWithCapacity:1]; diff --git a/ios/web_view/internal/cwv_html_element_unittest.mm b/ios/web_view/internal/cwv_html_element_unittest.mm index 55768ee8a65b42..eec4910e43eb27 100644 --- a/ios/web_view/internal/cwv_html_element_unittest.mm +++ b/ios/web_view/internal/cwv_html_element_unittest.mm @@ -8,6 +8,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -15,8 +16,10 @@ namespace ios_web_view { +using CWVHTMLElementTest = PlatformTest; + // Tests CWVHTMLElementTest initialization. -TEST(CWVHTMLElementTest, Initialization) { +TEST_F(CWVHTMLElementTest, Initialization) { NSURL* const hyperlink = [NSURL URLWithString:@"https://chromium.test"]; NSURL* const mediaSource = [NSURL URLWithString:@"https://chromium/img.webp"]; NSString* const text = @"link"; diff --git a/ios/web_view/internal/cwv_preview_element_info_unittest.mm b/ios/web_view/internal/cwv_preview_element_info_unittest.mm index 8f1a7b7d1ca662..eab981e744f27a 100644 --- a/ios/web_view/internal/cwv_preview_element_info_unittest.mm +++ b/ios/web_view/internal/cwv_preview_element_info_unittest.mm @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #import "testing/gtest_mac.h" +#include "testing/platform_test.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -13,8 +14,10 @@ namespace ios_web_view { +using CWVPreviewElementInfoTest = PlatformTest; + // Tests CWVPreviewElementInfoTest initialization. -TEST(CWVPreviewElementInfoTest, Initialization) { +TEST_F(CWVPreviewElementInfoTest, Initialization) { NSURL* const linkURL = [NSURL URLWithString:@"https://chromium.test"]; CWVPreviewElementInfo* element = [[CWVPreviewElementInfo alloc] initWithLinkURL:linkURL];