| 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" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return; | 146 return; |
| 147 } | 147 } |
| 148 | 148 |
| 149 MakeInactive(); | 149 MakeInactive(); |
| 150 base::scoped_nsobject<CRWTestBrowsingDataStoreObserver> observer( | 150 base::scoped_nsobject<CRWTestBrowsingDataStoreObserver> observer( |
| 151 [[CRWTestBrowsingDataStoreObserver alloc] | 151 [[CRWTestBrowsingDataStoreObserver alloc] |
| 152 initWithBrowsingDataStore:browsing_data_store_]); | 152 initWithBrowsingDataStore:browsing_data_store_]); |
| 153 EXPECT_EQ(0U, [observer modeChangeCount]); | 153 EXPECT_EQ(0U, [observer modeChangeCount]); |
| 154 | 154 |
| 155 __block int callbacks_received_count = 0; | 155 __block int callbacks_received_count = 0; |
| 156 void (^unsucessfullCallback)(BOOL) = ^(BOOL success) { | 156 void (^unsuccessfullCallback)(BOOL) = ^(BOOL success) { |
| 157 ASSERT_TRUE([NSThread isMainThread]); | 157 ASSERT_TRUE([NSThread isMainThread]); |
| 158 ++callbacks_received_count; | 158 ++callbacks_received_count; |
| 159 BrowsingDataStoreMode mode = [browsing_data_store_ mode]; | 159 BrowsingDataStoreMode mode = [browsing_data_store_ mode]; |
| 160 EXPECT_FALSE(success); | 160 EXPECT_FALSE(success); |
| 161 EXPECT_EQ(CHANGING, mode); | 161 EXPECT_EQ(CHANGING, mode); |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 [browsing_data_store_ makeActiveWithCompletionHandler:^(BOOL success) { | 164 [browsing_data_store_ makeActiveWithCompletionHandler:^(BOOL success) { |
| 165 EXPECT_EQ(0, callbacks_received_count); | 165 EXPECT_EQ(0, callbacks_received_count); |
| 166 unsucessfullCallback(success); | 166 unsuccessfullCallback(success); |
| 167 }]; | 167 }]; |
| 168 EXPECT_EQ(CHANGING, [browsing_data_store_ mode]); | 168 EXPECT_EQ(CHANGING, [browsing_data_store_ mode]); |
| 169 EXPECT_EQ(1U, [observer modeChangeCount]); | 169 EXPECT_EQ(1U, [observer modeChangeCount]); |
| 170 | 170 |
| 171 [browsing_data_store_ makeInactiveWithCompletionHandler:^(BOOL success) { | 171 [browsing_data_store_ makeInactiveWithCompletionHandler:^(BOOL success) { |
| 172 EXPECT_EQ(1, callbacks_received_count); | 172 EXPECT_EQ(1, callbacks_received_count); |
| 173 unsucessfullCallback(success); | 173 unsuccessfullCallback(success); |
| 174 }]; | 174 }]; |
| 175 EXPECT_EQ(CHANGING, [browsing_data_store_ mode]); | 175 EXPECT_EQ(CHANGING, [browsing_data_store_ mode]); |
| 176 | 176 |
| 177 [browsing_data_store_ makeActiveWithCompletionHandler:^(BOOL success) { | 177 [browsing_data_store_ makeActiveWithCompletionHandler:^(BOOL success) { |
| 178 EXPECT_EQ(2, callbacks_received_count); | 178 EXPECT_EQ(2, callbacks_received_count); |
| 179 unsucessfullCallback(success); | 179 unsuccessfullCallback(success); |
| 180 }]; | 180 }]; |
| 181 EXPECT_EQ(CHANGING, [browsing_data_store_ mode]); | 181 EXPECT_EQ(CHANGING, [browsing_data_store_ mode]); |
| 182 | 182 |
| 183 __block BOOL block_was_called = NO; | 183 __block BOOL block_was_called = NO; |
| 184 [browsing_data_store_ makeInactiveWithCompletionHandler:^(BOOL success) { | 184 [browsing_data_store_ makeInactiveWithCompletionHandler:^(BOOL success) { |
| 185 ASSERT_TRUE([NSThread isMainThread]); | 185 ASSERT_TRUE([NSThread isMainThread]); |
| 186 EXPECT_EQ(3, callbacks_received_count); | 186 EXPECT_EQ(3, callbacks_received_count); |
| 187 BrowsingDataStoreMode mode = [browsing_data_store_ mode]; | 187 BrowsingDataStoreMode mode = [browsing_data_store_ mode]; |
| 188 EXPECT_TRUE(success); | 188 EXPECT_TRUE(success); |
| 189 EXPECT_EQ(INACTIVE, mode); | 189 EXPECT_EQ(INACTIVE, mode); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 240 |
| 241 ASSERT_EQ(ACTIVE, [browsing_data_store_ mode]); | 241 ASSERT_EQ(ACTIVE, [browsing_data_store_ mode]); |
| 242 | 242 |
| 243 [browsing_data_store_ makeInactiveWithCompletionHandler:nil]; | 243 [browsing_data_store_ makeInactiveWithCompletionHandler:nil]; |
| 244 // |removeDataOfTypes| is called immediately after a |makeInactive| call. | 244 // |removeDataOfTypes| is called immediately after a |makeInactive| call. |
| 245 RemoveDataOfTypes(BROWSING_DATA_TYPE_COOKIES); | 245 RemoveDataOfTypes(BROWSING_DATA_TYPE_COOKIES); |
| 246 EXPECT_EQ(INACTIVE, [browsing_data_store_ mode]); | 246 EXPECT_EQ(INACTIVE, [browsing_data_store_ mode]); |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace web | 249 } // namespace web |
| OLD | NEW |