OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/chrome/app/application_delegate/background_activity.h" | 5 #import "ios/chrome/app/application_delegate/background_activity.h" |
6 | 6 |
7 #import "ios/chrome/app/application_delegate/browser_launcher.h" | 7 #import "ios/chrome/app/application_delegate/browser_launcher.h" |
8 #import "ios/chrome/app/application_delegate/metrics_mediator.h" | 8 #import "ios/chrome/app/application_delegate/metrics_mediator.h" |
9 #import "ios/chrome/browser/crash_report/crash_report_background_uploader.h" | 9 #import "ios/chrome/browser/crash_report/crash_report_background_uploader.h" |
10 #import "ios/chrome/browser/metrics/previous_session_info.h" | 10 #import "ios/chrome/browser/metrics/previous_session_info.h" |
11 #import "ios/chrome/browser/metrics/previous_session_info_private.h" | 11 #import "ios/chrome/browser/metrics/previous_session_info_private.h" |
12 #import "ios/chrome/test/base/scoped_block_swizzler.h" | 12 #import "ios/chrome/test/base/scoped_block_swizzler.h" |
13 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
14 #import "third_party/ocmock/OCMock/OCMock.h" | 14 #import "third_party/ocmock/OCMock/OCMock.h" |
15 #import "third_party/ocmock/gtest_support.h" | 15 #import "third_party/ocmock/gtest_support.h" |
16 | 16 |
| 17 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 18 #error "This file requires ARC support." |
| 19 #endif |
| 20 |
17 // Verifies that -application:performFetchWithCompletionHandler: calls the | 21 // Verifies that -application:performFetchWithCompletionHandler: calls the |
18 // browser launcher in background state and uploads the report. | 22 // browser launcher in background state and uploads the report. |
19 TEST(BackgroundActivityTest, performFetchWithCompletionHandler) { | 23 TEST(BackgroundActivityTest, performFetchWithCompletionHandler) { |
20 // Setup. | 24 // Setup. |
21 [[PreviousSessionInfo sharedInstance] setIsFirstSessionAfterUpgrade:NO]; | 25 [[PreviousSessionInfo sharedInstance] setIsFirstSessionAfterUpgrade:NO]; |
22 | 26 |
23 // MetricsMediator mock. | 27 // MetricsMediator mock. |
24 id metrics_mediator_mock = | 28 id metrics_mediator_mock = |
25 [OCMockObject mockForClass:[MetricsMediator class]]; | 29 [OCMockObject mockForClass:[MetricsMediator class]]; |
26 [[[metrics_mediator_mock stub] andReturnValue:@YES] areMetricsEnabled]; | 30 [[[metrics_mediator_mock stub] andReturnValue:@YES] areMetricsEnabled]; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 68 |
65 // Test. | 69 // Test. |
66 [BackgroundActivity handleEventsForBackgroundURLSession:nil | 70 [BackgroundActivity handleEventsForBackgroundURLSession:nil |
67 completionHandler:^{ | 71 completionHandler:^{ |
68 } | 72 } |
69 browserLauncher:browser_launcher]; | 73 browserLauncher:browser_launcher]; |
70 | 74 |
71 // Check. | 75 // Check. |
72 EXPECT_OCMOCK_VERIFY(browser_launcher); | 76 EXPECT_OCMOCK_VERIFY(browser_launcher); |
73 } | 77 } |
OLD | NEW |