OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/browsing_data/browsing_data_removal_controller.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #import "base/mac/scoped_nsobject.h" |
| 10 #import "base/test/ios/wait_util.h" |
| 11 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 12 #include "ios/web/public/test/web_test.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #import "third_party/ocmock/OCMock/OCMock.h" |
| 15 #import "third_party/ocmock/gtest_support.h" |
| 16 |
| 17 typedef web::WebTest BrowsingDataRemovalControllerTest; |
| 18 |
| 19 // Tests that |removeIOSSpecificIncognitoBrowsingDataFromBrowserState:| can |
| 20 // finish performing its operation even when a BrowserState is destroyed. |
| 21 TEST_F(BrowsingDataRemovalControllerTest, PerformAfterBrowserStateDestruction) { |
| 22 __block BOOL block_was_called = NO; |
| 23 id mock_delegate = [OCMockObject |
| 24 mockForProtocol:@protocol(BrowsingDataRemovalControllerDelegate)]; |
| 25 base::scoped_nsobject<BrowsingDataRemovalController> removal_controller( |
| 26 [[BrowsingDataRemovalController alloc] initWithDelegate:mock_delegate]); |
| 27 |
| 28 TestChromeBrowserState::Builder builder; |
| 29 std::unique_ptr<TestChromeBrowserState> browser_state = builder.Build(); |
| 30 ios::ChromeBrowserState* otr_browser_state = |
| 31 browser_state->GetOffTheRecordChromeBrowserState(); |
| 32 int remove_all_mask = ~0; |
| 33 [removal_controller |
| 34 removeIOSSpecificIncognitoBrowsingDataFromBrowserState:otr_browser_state |
| 35 mask:remove_all_mask |
| 36 completionHandler:^{ |
| 37 block_was_called = YES; |
| 38 }]; |
| 39 // Destroy the BrowserState immediately. |
| 40 browser_state->DestroyOffTheRecordChromeBrowserState(); |
| 41 |
| 42 base::test::ios::WaitUntilCondition(^bool() { |
| 43 return block_was_called; |
| 44 }); |
| 45 } |
OLD | NEW |