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

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

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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 #include "ios/web/web_state/web_state_impl.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 8
9 #include <memory>
10
7 #include "base/bind.h" 11 #include "base/bind.h"
8 #include "base/logging.h" 12 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h" 13 #include "base/values.h"
11 #include "ios/web/public/load_committed_details.h" 14 #include "ios/web/public/load_committed_details.h"
12 #include "ios/web/public/test/test_browser_state.h" 15 #include "ios/web/public/test/test_browser_state.h"
13 #include "ios/web/public/web_state/global_web_state_observer.h" 16 #include "ios/web/public/web_state/global_web_state_observer.h"
14 #include "ios/web/public/web_state/web_state_observer.h" 17 #include "ios/web/public/web_state/web_state_observer.h"
15 #include "ios/web/public/web_state/web_state_policy_decider.h" 18 #include "ios/web/public/web_state/web_state_policy_decider.h"
16 #include "ios/web/web_state/global_web_state_event_tracker.h" 19 #include "ios/web/web_state/global_web_state_event_tracker.h"
17 #include "ios/web/web_state/web_state_impl.h"
18 #include "net/http/http_response_headers.h" 20 #include "net/http/http_response_headers.h"
19 #include "net/http/http_util.h" 21 #include "net/http/http_util.h"
20 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/gtest_mac.h" 24 #include "testing/gtest_mac.h"
23 #include "testing/platform_test.h" 25 #include "testing/platform_test.h"
24 #include "url/gurl.h" 26 #include "url/gurl.h"
25 27
26 using testing::_; 28 using testing::_;
27 using testing::Assign; 29 using testing::Assign;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 225 }
224 226
225 class WebStateTest : public PlatformTest { 227 class WebStateTest : public PlatformTest {
226 protected: 228 protected:
227 void SetUp() override { 229 void SetUp() override {
228 web_state_.reset(new WebStateImpl(&browser_state_)); 230 web_state_.reset(new WebStateImpl(&browser_state_));
229 web_state_->SetWebController(nil); 231 web_state_->SetWebController(nil);
230 } 232 }
231 233
232 web::TestBrowserState browser_state_; 234 web::TestBrowserState browser_state_;
233 scoped_ptr<WebStateImpl> web_state_; 235 std::unique_ptr<WebStateImpl> web_state_;
234 }; 236 };
235 237
236 TEST_F(WebStateTest, ResponseHeaders) { 238 TEST_F(WebStateTest, ResponseHeaders) {
237 GURL real_url("http://foo.com/bar"); 239 GURL real_url("http://foo.com/bar");
238 GURL frame_url("http://frames-r-us.com/"); 240 GURL frame_url("http://frames-r-us.com/");
239 scoped_refptr<net::HttpResponseHeaders> real_headers(HeadersFromString( 241 scoped_refptr<net::HttpResponseHeaders> real_headers(HeadersFromString(
240 "HTTP/1.1 200 OK\r\n" 242 "HTTP/1.1 200 OK\r\n"
241 "Content-Type: text/html\r\n" 243 "Content-Type: text/html\r\n"
242 "Content-Language: en\r\n" 244 "Content-Language: en\r\n"
243 "X-Should-Be-Here: yep\r\n" 245 "X-Should-Be-Here: yep\r\n"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 288
287 // ... but not after loading another page, nor should there be specific 289 // ... but not after loading another page, nor should there be specific
288 // parsed values. 290 // parsed values.
289 web_state_->OnNavigationCommitted(GURL("http://elsewhere.com/")); 291 web_state_->OnNavigationCommitted(GURL("http://elsewhere.com/"));
290 EXPECT_EQ(NULL, web_state_->GetHttpResponseHeaders()); 292 EXPECT_EQ(NULL, web_state_->GetHttpResponseHeaders());
291 EXPECT_EQ("", web_state_->GetContentsMimeType()); 293 EXPECT_EQ("", web_state_->GetContentsMimeType());
292 EXPECT_EQ("", web_state_->GetContentLanguageHeader()); 294 EXPECT_EQ("", web_state_->GetContentLanguageHeader());
293 } 295 }
294 296
295 TEST_F(WebStateTest, ObserverTest) { 297 TEST_F(WebStateTest, ObserverTest) {
296 scoped_ptr<TestWebStateObserver> observer( 298 std::unique_ptr<TestWebStateObserver> observer(
297 new TestWebStateObserver(web_state_.get())); 299 new TestWebStateObserver(web_state_.get()));
298 EXPECT_EQ(web_state_.get(), observer->web_state()); 300 EXPECT_EQ(web_state_.get(), observer->web_state());
299 301
300 // Test that ProvisionalNavigationStarted() is called. 302 // Test that ProvisionalNavigationStarted() is called.
301 EXPECT_FALSE(observer->provisional_navigation_started_called()); 303 EXPECT_FALSE(observer->provisional_navigation_started_called());
302 web_state_->OnProvisionalNavigationStarted(GURL("http://test")); 304 web_state_->OnProvisionalNavigationStarted(GURL("http://test"));
303 EXPECT_TRUE(observer->provisional_navigation_started_called()); 305 EXPECT_TRUE(observer->provisional_navigation_started_called());
304 306
305 // Test that NavigationItemsPruned() is called. 307 // Test that NavigationItemsPruned() is called.
306 EXPECT_FALSE(observer->navigation_items_pruned_called()); 308 EXPECT_FALSE(observer->navigation_items_pruned_called());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // Test that WebStateDestroyed() is called. 340 // Test that WebStateDestroyed() is called.
339 EXPECT_FALSE(observer->web_state_destroyed_called()); 341 EXPECT_FALSE(observer->web_state_destroyed_called());
340 web_state_.reset(); 342 web_state_.reset();
341 EXPECT_TRUE(observer->web_state_destroyed_called()); 343 EXPECT_TRUE(observer->web_state_destroyed_called());
342 344
343 EXPECT_EQ(nullptr, observer->web_state()); 345 EXPECT_EQ(nullptr, observer->web_state());
344 } 346 }
345 347
346 // Verifies that GlobalWebStateObservers are called when expected. 348 // Verifies that GlobalWebStateObservers are called when expected.
347 TEST_F(WebStateTest, GlobalObserverTest) { 349 TEST_F(WebStateTest, GlobalObserverTest) {
348 scoped_ptr<TestGlobalWebStateObserver> observer( 350 std::unique_ptr<TestGlobalWebStateObserver> observer(
349 new TestGlobalWebStateObserver()); 351 new TestGlobalWebStateObserver());
350 352
351 // Test that NavigationItemsPruned() is called. 353 // Test that NavigationItemsPruned() is called.
352 EXPECT_FALSE(observer->navigation_items_pruned_called()); 354 EXPECT_FALSE(observer->navigation_items_pruned_called());
353 web_state_->OnNavigationItemsPruned(1); 355 web_state_->OnNavigationItemsPruned(1);
354 EXPECT_TRUE(observer->navigation_items_pruned_called()); 356 EXPECT_TRUE(observer->navigation_items_pruned_called());
355 357
356 // Test that NavigationItemChanged() is called. 358 // Test that NavigationItemChanged() is called.
357 EXPECT_FALSE(observer->navigation_item_changed_called()); 359 EXPECT_FALSE(observer->navigation_item_changed_called());
358 web_state_->OnNavigationItemChanged(); 360 web_state_->OnNavigationItemChanged();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 EXPECT_FALSE( 495 EXPECT_FALSE(
494 web_state_->OnScriptCommandReceived(kCommand2, value_2, kUrl2, false)); 496 web_state_->OnScriptCommandReceived(kCommand2, value_2, kUrl2, false));
495 EXPECT_FALSE(is_called_1); 497 EXPECT_FALSE(is_called_1);
496 EXPECT_TRUE(is_called_2); 498 EXPECT_TRUE(is_called_2);
497 499
498 web_state_->RemoveScriptCommandCallback(kPrefix2); 500 web_state_->RemoveScriptCommandCallback(kPrefix2);
499 } 501 }
500 502
501 } // namespace 503 } // namespace
502 } // namespace web 504 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/web_state/web_state_impl.h ('k') | ios/web/web_state/web_view_internal_creation_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698