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

Side by Side Diff: ios/web/web_state/web_state_impl_unittest.mm

Issue 2935933003: [ObjC ARC] Converts ios/web:ios_web_web_state_unittests to ARC. (Closed)
Patch Set: Review fixes. Created 3 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/web_state/web_state_impl.h" 5 #import "ios/web/web_state/web_state_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 17 matching lines...) Expand all
28 #include "ios/web/web_state/global_web_state_event_tracker.h" 28 #include "ios/web/web_state/global_web_state_event_tracker.h"
29 #import "ios/web/web_state/navigation_context_impl.h" 29 #import "ios/web/web_state/navigation_context_impl.h"
30 #import "ios/web/web_state/ui/crw_web_controller.h" 30 #import "ios/web/web_state/ui/crw_web_controller.h"
31 #include "net/http/http_response_headers.h" 31 #include "net/http/http_response_headers.h"
32 #include "net/http/http_util.h" 32 #include "net/http/http_util.h"
33 #include "testing/gmock/include/gmock/gmock.h" 33 #include "testing/gmock/include/gmock/gmock.h"
34 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
35 #import "testing/gtest_mac.h" 35 #import "testing/gtest_mac.h"
36 #include "url/gurl.h" 36 #include "url/gurl.h"
37 37
38 #if !defined(__has_feature) || !__has_feature(objc_arc)
39 #error "This file requires ARC support."
40 #endif
41
38 using testing::_; 42 using testing::_;
39 using testing::Assign; 43 using testing::Assign;
40 using testing::AtMost; 44 using testing::AtMost;
41 using testing::DoAll; 45 using testing::DoAll;
42 using testing::Return; 46 using testing::Return;
43 47
44 namespace web { 48 namespace web {
45 namespace { 49 namespace {
46 50
47 // Test observer to check that the GlobalWebStateObserver methods are called as 51 // Test observer to check that the GlobalWebStateObserver methods are called as
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 496
493 // Test that GetJavaScriptDialogPresenter() is called. 497 // Test that GetJavaScriptDialogPresenter() is called.
494 TestJavaScriptDialogPresenter* presenter = 498 TestJavaScriptDialogPresenter* presenter =
495 delegate.GetTestJavaScriptDialogPresenter(); 499 delegate.GetTestJavaScriptDialogPresenter();
496 EXPECT_FALSE(delegate.get_java_script_dialog_presenter_called()); 500 EXPECT_FALSE(delegate.get_java_script_dialog_presenter_called());
497 EXPECT_TRUE(presenter->requested_dialogs().empty()); 501 EXPECT_TRUE(presenter->requested_dialogs().empty());
498 EXPECT_FALSE(presenter->cancel_dialogs_called()); 502 EXPECT_FALSE(presenter->cancel_dialogs_called());
499 503
500 __block bool callback_called = false; 504 __block bool callback_called = false;
501 web_state_->RunJavaScriptDialog(GURL(), JAVASCRIPT_DIALOG_TYPE_ALERT, @"", 505 web_state_->RunJavaScriptDialog(GURL(), JAVASCRIPT_DIALOG_TYPE_ALERT, @"",
502 nil, base::BindBlock(^(bool, NSString*) { 506 nil, base::BindBlockArc(^(bool, NSString*) {
503 callback_called = true; 507 callback_called = true;
504 })); 508 }));
505 509
506 EXPECT_TRUE(delegate.get_java_script_dialog_presenter_called()); 510 EXPECT_TRUE(delegate.get_java_script_dialog_presenter_called());
507 EXPECT_EQ(1U, presenter->requested_dialogs().size()); 511 EXPECT_EQ(1U, presenter->requested_dialogs().size());
508 EXPECT_TRUE(callback_called); 512 EXPECT_TRUE(callback_called);
509 513
510 EXPECT_FALSE(presenter->cancel_dialogs_called()); 514 EXPECT_FALSE(presenter->cancel_dialogs_called());
511 web_state_->CancelDialogs(); 515 web_state_->CancelDialogs();
512 EXPECT_TRUE(presenter->cancel_dialogs_called()); 516 EXPECT_TRUE(presenter->cancel_dialogs_called());
513 517
514 // Test that OnAuthRequired() is called. 518 // Test that OnAuthRequired() is called.
515 EXPECT_FALSE(delegate.last_authentication_request()); 519 EXPECT_FALSE(delegate.last_authentication_request());
516 base::scoped_nsobject<NSURLProtectionSpace> protection_space( 520 NSURLProtectionSpace* protection_space = [[NSURLProtectionSpace alloc] init];
517 [[NSURLProtectionSpace alloc] init]); 521 NSURLCredential* credential = [[NSURLCredential alloc] init];
518 base::scoped_nsobject<NSURLCredential> credential(
519 [[NSURLCredential alloc] init]);
520 WebStateDelegate::AuthCallback callback; 522 WebStateDelegate::AuthCallback callback;
521 web_state_->OnAuthRequired(protection_space.get(), credential.get(), 523 web_state_->OnAuthRequired(protection_space, credential, callback);
522 callback);
523 ASSERT_TRUE(delegate.last_authentication_request()); 524 ASSERT_TRUE(delegate.last_authentication_request());
524 EXPECT_EQ(delegate.last_authentication_request()->web_state, 525 EXPECT_EQ(delegate.last_authentication_request()->web_state,
525 web_state_.get()); 526 web_state_.get());
526 EXPECT_EQ(delegate.last_authentication_request()->protection_space, 527 EXPECT_EQ(delegate.last_authentication_request()->protection_space,
527 protection_space.get()); 528 protection_space);
528 EXPECT_EQ(delegate.last_authentication_request()->credential, 529 EXPECT_EQ(delegate.last_authentication_request()->credential, credential);
529 credential.get());
530 } 530 }
531 531
532 // Verifies that GlobalWebStateObservers are called when expected. 532 // Verifies that GlobalWebStateObservers are called when expected.
533 TEST_F(WebStateImplTest, GlobalObserverTest) { 533 TEST_F(WebStateImplTest, GlobalObserverTest) {
534 std::unique_ptr<TestGlobalWebStateObserver> observer( 534 std::unique_ptr<TestGlobalWebStateObserver> observer(
535 new TestGlobalWebStateObserver()); 535 new TestGlobalWebStateObserver());
536 536
537 // Test that NavigationItemsPruned() is called. 537 // Test that NavigationItemsPruned() is called.
538 EXPECT_FALSE(observer->navigation_items_pruned_called()); 538 EXPECT_FALSE(observer->navigation_items_pruned_called());
539 web_state_->OnNavigationItemsPruned(1); 539 web_state_->OnNavigationItemsPruned(1);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 // Set |created_with_opener| to true and verify that HasOpener() returns true. 693 // Set |created_with_opener| to true and verify that HasOpener() returns true.
694 WebState::CreateParams params_with_opener = 694 WebState::CreateParams params_with_opener =
695 WebState::CreateParams(GetBrowserState()); 695 WebState::CreateParams(GetBrowserState());
696 params_with_opener.created_with_opener = true; 696 params_with_opener.created_with_opener = true;
697 std::unique_ptr<WebState> web_state_with_opener = 697 std::unique_ptr<WebState> web_state_with_opener =
698 WebState::Create(params_with_opener); 698 WebState::Create(params_with_opener);
699 EXPECT_TRUE(web_state_with_opener->HasOpener()); 699 EXPECT_TRUE(web_state_with_opener->HasOpener());
700 } 700 }
701 701
702 } // namespace web 702 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/web_state/web_state_delegate_bridge_unittest.mm ('k') | ios/web/web_state/web_state_observer_bridge_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698