OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/web/public/crw_browsing_data_store.h" | 5 #import "ios/web/public/crw_browsing_data_store.h" |
6 | 6 |
7 #include "base/ios/ios_util.h" | 7 #include "base/ios/ios_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #import "base/test/ios/wait_util.h" | 11 #import "base/test/ios/wait_util.h" |
12 #include "ios/web/public/active_state_manager.h" | 12 #include "ios/web/public/active_state_manager.h" |
13 #include "ios/web/public/browser_state.h" | 13 #include "ios/web/public/browser_state.h" |
14 #include "ios/web/public/test/test_browser_state.h" | 14 #include "ios/web/public/test/test_browser_state.h" |
15 #include "ios/web/public/test/test_web_thread_bundle.h" | 15 #include "ios/web/public/test/test_web_thread_bundle.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
18 | 18 |
19 // An observer to observe the |mode| key changes to a CRWBrowsingDataStore. | 19 // An observer to observe the |mode| key changes to a CRWBrowsingDataStore. |
20 // Used for testing purposes. | 20 // Used for testing purposes. |
21 @interface CRWTestBrowsingDataStoreObserver : NSObject | 21 @interface CRWTestBrowsingDataStoreObserver : NSObject |
22 - (instancetype)init UNAVAILABLE_ATTRIBUTE; | |
droger
2015/06/10 15:59:10
NS_UNAVAILABLE
justincohen
2015/06/10 16:02:25
Done.
| |
22 // Designated init. |browsingDataStore| cannot be null. | 23 // Designated init. |browsingDataStore| cannot be null. |
23 - (instancetype)initWithBrowsingDataStore: | 24 - (instancetype)initWithBrowsingDataStore: |
24 (CRWBrowsingDataStore*)browsingDataStore NS_DESIGNATED_INITIALIZER; | 25 (CRWBrowsingDataStore*)browsingDataStore NS_DESIGNATED_INITIALIZER; |
25 // The number of times that the mode of the underlying CRWBrowsingDataStore | 26 // The number of times that the mode of the underlying CRWBrowsingDataStore |
26 // changed. | 27 // changed. |
27 @property(nonatomic, assign) NSUInteger modeChangeCount; | 28 @property(nonatomic, assign) NSUInteger modeChangeCount; |
28 @end | 29 @end |
29 | 30 |
30 @implementation CRWTestBrowsingDataStoreObserver { | 31 @implementation CRWTestBrowsingDataStoreObserver { |
31 // The underlying CRWBrowsingDataStore. | 32 // The underlying CRWBrowsingDataStore. |
32 __weak CRWBrowsingDataStore* _browsingDataStore; | 33 __weak CRWBrowsingDataStore* _browsingDataStore; |
33 } | 34 } |
34 | 35 |
35 @synthesize modeChangeCount = _modeChangeCount; | 36 @synthesize modeChangeCount = _modeChangeCount; |
36 | 37 |
38 - (instancetype)init { | |
39 NOTREACHED(); | |
40 return nil; | |
41 } | |
42 | |
37 - (instancetype)initWithBrowsingDataStore: | 43 - (instancetype)initWithBrowsingDataStore: |
38 (CRWBrowsingDataStore*)browsingDataStore { | 44 (CRWBrowsingDataStore*)browsingDataStore { |
39 self = [super init]; | 45 self = [super init]; |
40 if (self) { | 46 if (self) { |
41 DCHECK(browsingDataStore); | 47 DCHECK(browsingDataStore); |
42 [browsingDataStore addObserver:self | 48 [browsingDataStore addObserver:self |
43 forKeyPath:@"mode" | 49 forKeyPath:@"mode" |
44 options:0 | 50 options:0 |
45 context:nil]; | 51 context:nil]; |
46 _browsingDataStore = browsingDataStore; | 52 _browsingDataStore = browsingDataStore; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 | 237 |
232 ASSERT_EQ(ACTIVE, [browsing_data_store_ mode]); | 238 ASSERT_EQ(ACTIVE, [browsing_data_store_ mode]); |
233 | 239 |
234 [browsing_data_store_ makeInactiveWithCompletionHandler:nil]; | 240 [browsing_data_store_ makeInactiveWithCompletionHandler:nil]; |
235 // |removeDataOfTypes| is called immediately after a |makeInactive| call. | 241 // |removeDataOfTypes| is called immediately after a |makeInactive| call. |
236 RemoveDataOfTypes(BROWSING_DATA_TYPE_COOKIES); | 242 RemoveDataOfTypes(BROWSING_DATA_TYPE_COOKIES); |
237 EXPECT_EQ(INACTIVE, [browsing_data_store_ mode]); | 243 EXPECT_EQ(INACTIVE, [browsing_data_store_ mode]); |
238 } | 244 } |
239 | 245 |
240 } // namespace web | 246 } // namespace web |
OLD | NEW |