Chromium Code Reviews| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 } | 151 } |
| 152 | 152 |
| 153 MakeInactive(); | 153 MakeInactive(); |
| 154 base::scoped_nsobject<CRWTestBrowsingDataStoreObserver> observer( | 154 base::scoped_nsobject<CRWTestBrowsingDataStoreObserver> observer( |
| 155 [[CRWTestBrowsingDataStoreObserver alloc] | 155 [[CRWTestBrowsingDataStoreObserver alloc] |
| 156 initWithBrowsingDataStore:browsing_data_store_]); | 156 initWithBrowsingDataStore:browsing_data_store_]); |
| 157 EXPECT_EQ(0U, [observer modeChangeCount]); | 157 EXPECT_EQ(0U, [observer modeChangeCount]); |
| 158 | 158 |
| 159 id unsucessfullCallback = ^(BOOL success) { | 159 id unsucessfullCallback = ^(BOOL success) { |
| 160 ASSERT_TRUE([NSThread isMainThread]); | 160 ASSERT_TRUE([NSThread isMainThread]); |
| 161 CRWBrowsingDataStoreMode mode = [browsing_data_store_ mode]; | 161 web::BrowsingDataStoreMode mode = [browsing_data_store_ mode]; |
|
Eugene But (OOO till 7-30)
2015/06/04 15:42:59
Drop web:: this code is already in web namespace.
shreyasv1
2015/06/05 21:05:51
Done.
| |
| 162 EXPECT_FALSE(success); | 162 EXPECT_FALSE(success); |
| 163 EXPECT_EQ(SYNCHRONIZING, mode); | 163 EXPECT_EQ(CHANGING, mode); |
| 164 }; | 164 }; |
| 165 [browsing_data_store_ makeActiveWithCompletionHandler:unsucessfullCallback]; | 165 [browsing_data_store_ makeActiveWithCompletionHandler:unsucessfullCallback]; |
| 166 EXPECT_EQ(SYNCHRONIZING, [browsing_data_store_ mode]); | 166 EXPECT_EQ(CHANGING, [browsing_data_store_ mode]); |
| 167 EXPECT_EQ(1U, [observer modeChangeCount]); | 167 EXPECT_EQ(1U, [observer modeChangeCount]); |
| 168 | 168 |
| 169 [browsing_data_store_ makeInactiveWithCompletionHandler:unsucessfullCallback]; | 169 [browsing_data_store_ makeInactiveWithCompletionHandler:unsucessfullCallback]; |
| 170 EXPECT_EQ(SYNCHRONIZING, [browsing_data_store_ mode]); | 170 EXPECT_EQ(CHANGING, [browsing_data_store_ mode]); |
| 171 | 171 |
| 172 [browsing_data_store_ makeActiveWithCompletionHandler:unsucessfullCallback]; | 172 [browsing_data_store_ makeActiveWithCompletionHandler:unsucessfullCallback]; |
| 173 EXPECT_EQ(SYNCHRONIZING, [browsing_data_store_ mode]); | 173 EXPECT_EQ(CHANGING, [browsing_data_store_ mode]); |
| 174 | 174 |
| 175 __block BOOL block_was_called = NO; | 175 __block BOOL block_was_called = NO; |
| 176 [browsing_data_store_ makeInactiveWithCompletionHandler:^(BOOL success) { | 176 [browsing_data_store_ makeInactiveWithCompletionHandler:^(BOOL success) { |
| 177 ASSERT_TRUE([NSThread isMainThread]); | 177 ASSERT_TRUE([NSThread isMainThread]); |
| 178 CRWBrowsingDataStoreMode mode = [browsing_data_store_ mode]; | 178 web::BrowsingDataStoreMode mode = [browsing_data_store_ mode]; |
|
Eugene But (OOO till 7-30)
2015/06/04 15:42:58
ditto
shreyasv1
2015/06/05 21:05:51
Done.
| |
| 179 EXPECT_TRUE(success); | 179 EXPECT_TRUE(success); |
| 180 EXPECT_EQ(INACTIVE, mode); | 180 EXPECT_EQ(INACTIVE, mode); |
| 181 block_was_called = YES; | 181 block_was_called = YES; |
| 182 }]; | 182 }]; |
| 183 EXPECT_EQ(SYNCHRONIZING, [browsing_data_store_ mode]); | 183 EXPECT_EQ(CHANGING, [browsing_data_store_ mode]); |
| 184 | 184 |
| 185 base::test::ios::WaitUntilCondition(^bool{ | 185 base::test::ios::WaitUntilCondition(^bool{ |
| 186 return block_was_called; | 186 return block_was_called; |
| 187 }); | 187 }); |
| 188 | 188 |
| 189 EXPECT_EQ(INACTIVE, [browsing_data_store_ mode]); | 189 EXPECT_EQ(INACTIVE, [browsing_data_store_ mode]); |
| 190 EXPECT_EQ(2U, [observer modeChangeCount]); | 190 EXPECT_EQ(2U, [observer modeChangeCount]); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // Tests that CRWBrowsingDataStore correctly handles |removeDataOfTypes:|. | 193 // Tests that CRWBrowsingDataStore correctly handles |removeDataOfTypes:|. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 | 231 |
| 232 ASSERT_EQ(ACTIVE, [browsing_data_store_ mode]); | 232 ASSERT_EQ(ACTIVE, [browsing_data_store_ mode]); |
| 233 | 233 |
| 234 [browsing_data_store_ makeInactiveWithCompletionHandler:nil]; | 234 [browsing_data_store_ makeInactiveWithCompletionHandler:nil]; |
| 235 // |removeDataOfTypes| is called immediately after a |makeInactive| call. | 235 // |removeDataOfTypes| is called immediately after a |makeInactive| call. |
| 236 RemoveDataOfTypes(BROWSING_DATA_TYPE_COOKIES); | 236 RemoveDataOfTypes(BROWSING_DATA_TYPE_COOKIES); |
| 237 EXPECT_EQ(INACTIVE, [browsing_data_store_ mode]); | 237 EXPECT_EQ(INACTIVE, [browsing_data_store_ mode]); |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace web | 240 } // namespace web |
| OLD | NEW |