Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: ios/chrome/browser/ui/dialogs/dialog_presenter_unittest.mm

Issue 2686913003: [ObjC ARC] Converts ios/chrome/browser/ui/dialogs:unit_tests_internal to ARC. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/chrome/browser/ui/dialogs/dialog_presenter.h" 5 #import "ios/chrome/browser/ui/dialogs/dialog_presenter.h"
6 6
7 #import "base/mac/scoped_nsobject.h"
8 #include "base/time/time.h" 7 #include "base/time/time.h"
9 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" 8 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h"
10 #import "ios/web/public/test/fakes/test_web_state.h" 9 #import "ios/web/public/test/fakes/test_web_state.h"
11 #include "ios/web/public/web_state/web_state_observer.h" 10 #include "ios/web/public/web_state/web_state_observer.h"
12 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/gtest_mac.h" 12 #include "testing/gtest_mac.h"
14 #include "testing/platform_test.h" 13 #include "testing/platform_test.h"
15 #include "url/gurl.h" 14 #include "url/gurl.h"
16 15
16 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 #error "This file requires ARC support."
18 #endif
19
17 namespace { 20 namespace {
18 // TestWebState subclass that supports the WebStateDestroyed() callback for a 21 // TestWebState subclass that supports the WebStateDestroyed() callback for a
19 // single observer. 22 // single observer.
20 class DialogPresenterTestWebState : public web::TestWebState { 23 class DialogPresenterTestWebState : public web::TestWebState {
21 public: 24 public:
22 DialogPresenterTestWebState() : web::TestWebState(), observer_(nullptr) {} 25 DialogPresenterTestWebState() : web::TestWebState(), observer_(nullptr) {}
23 ~DialogPresenterTestWebState() override { 26 ~DialogPresenterTestWebState() override {
24 if (observer_) 27 if (observer_)
25 observer_->WebStateDestroyed(); 28 observer_->WebStateDestroyed();
26 } 29 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 73 }
71 ~DialogPresenterTest() override { 74 ~DialogPresenterTest() override {
72 [[presenter_ presentedDialogCoordinator] stop]; 75 [[presenter_ presentedDialogCoordinator] stop];
73 } 76 }
74 77
75 TestDialogPresenterDelegate* delegate() { return delegate_; } 78 TestDialogPresenterDelegate* delegate() { return delegate_; }
76 UIViewController* viewController() { return viewController_; } 79 UIViewController* viewController() { return viewController_; }
77 DialogPresenter* presenter() { return presenter_; } 80 DialogPresenter* presenter() { return presenter_; }
78 81
79 private: 82 private:
80 base::scoped_nsobject<TestDialogPresenterDelegate> delegate_; 83 TestDialogPresenterDelegate* delegate_;
81 base::scoped_nsobject<UIViewController> viewController_; 84 UIViewController* viewController_;
82 base::scoped_nsobject<DialogPresenter> presenter_; 85 DialogPresenter* presenter_;
83 }; 86 };
84 87
85 // Tests that a dialog was successfully shown and that the delegate was notified 88 // Tests that a dialog was successfully shown and that the delegate was notified
86 // with the correct context. 89 // with the correct context.
87 TEST_F(DialogPresenterTest, SimpleTest) { 90 TEST_F(DialogPresenterTest, SimpleTest) {
88 DialogPresenterTestWebState webState; 91 DialogPresenterTestWebState webState;
89 [presenter() runJavaScriptAlertPanelWithMessage:@"" 92 [presenter() runJavaScriptAlertPanelWithMessage:@""
90 requestURL:GURL() 93 requestURL:GURL()
91 webState:&webState 94 webState:&webState
92 completionHandler:nil]; 95 completionHandler:nil];
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 completion3_called = YES; 205 completion3_called = YES;
203 }]; 206 }];
204 EXPECT_EQ(1U, delegate().presentedWebStates.size()); 207 EXPECT_EQ(1U, delegate().presentedWebStates.size());
205 EXPECT_EQ(&webState1, delegate().presentedWebStates.front()); 208 EXPECT_EQ(&webState1, delegate().presentedWebStates.front());
206 // Cancel all dialogs and verify that all |completion_called| were called. 209 // Cancel all dialogs and verify that all |completion_called| were called.
207 [presenter() cancelAllDialogs]; 210 [presenter() cancelAllDialogs];
208 EXPECT_TRUE(completion1_called); 211 EXPECT_TRUE(completion1_called);
209 EXPECT_TRUE(completion2_called); 212 EXPECT_TRUE(completion2_called);
210 EXPECT_TRUE(completion3_called); 213 EXPECT_TRUE(completion3_called);
211 } 214 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/dialogs/BUILD.gn ('k') | ios/chrome/browser/ui/dialogs/nsurl_protection_space_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698