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/deferred_initialization_runner.h" | 5 #import "ios/chrome/app/deferred_initialization_runner.h" |
6 | 6 |
7 #import "base/test/ios/wait_util.h" | 7 #import "base/test/ios/wait_util.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "testing/platform_test.h" | 9 #include "testing/platform_test.h" |
10 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
11 TEST(DeferredInitializationRunnerTest, TestSharedInstance) { | 15 TEST(DeferredInitializationRunnerTest, TestSharedInstance) { |
12 EXPECT_TRUE([DeferredInitializationRunner sharedInstance]); | 16 EXPECT_TRUE([DeferredInitializationRunner sharedInstance]); |
13 // Cancelling a non-existing block does nothing. | 17 // Cancelling a non-existing block does nothing. |
14 [[DeferredInitializationRunner sharedInstance] | 18 [[DeferredInitializationRunner sharedInstance] |
15 cancelBlockNamed:@"Invalid Name"]; | 19 cancelBlockNamed:@"Invalid Name"]; |
16 } | 20 } |
17 | 21 |
18 // Tests that all blocks added on the queue are executed after a delay. | 22 // Tests that all blocks added on the queue are executed after a delay. |
19 TEST(DeferredInitializationRunnerTest, TestRunBlockSequentially) { | 23 TEST(DeferredInitializationRunnerTest, TestRunBlockSequentially) { |
20 // Setup. | 24 // Setup. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // Action. | 159 // Action. |
156 [runner enqueueBlockNamed:@"multiple" block:runBlock]; | 160 [runner enqueueBlockNamed:@"multiple" block:runBlock]; |
157 [runner enqueueBlockNamed:@"multiple" block:runBlock]; | 161 [runner enqueueBlockNamed:@"multiple" block:runBlock]; |
158 | 162 |
159 // Test: |runBlock| was executed only once. | 163 // Test: |runBlock| was executed only once. |
160 EXPECT_EQ(1U, [runner numberOfBlocksRemaining]); | 164 EXPECT_EQ(1U, [runner numberOfBlocksRemaining]); |
161 [runner runBlockIfNecessary:@"multiple"]; | 165 [runner runBlockIfNecessary:@"multiple"]; |
162 EXPECT_EQ(0U, [runner numberOfBlocksRemaining]); | 166 EXPECT_EQ(0U, [runner numberOfBlocksRemaining]); |
163 EXPECT_EQ(1, blockRunCount); | 167 EXPECT_EQ(1, blockRunCount); |
164 } | 168 } |
OLD | NEW |