OLD | NEW |
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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 SetIgnoreRenderProcessCrashesDuringTesting(true); | 344 SetIgnoreRenderProcessCrashesDuringTesting(true); |
345 ASSERT_FALSE(observer->render_process_gone_info()); | 345 ASSERT_FALSE(observer->render_process_gone_info()); |
346 web_state_->OnRenderProcessGone(); | 346 web_state_->OnRenderProcessGone(); |
347 ASSERT_TRUE(observer->render_process_gone_info()); | 347 ASSERT_TRUE(observer->render_process_gone_info()); |
348 EXPECT_EQ(web_state_.get(), observer->render_process_gone_info()->web_state); | 348 EXPECT_EQ(web_state_.get(), observer->render_process_gone_info()->web_state); |
349 | 349 |
350 // Test that ProvisionalNavigationStarted() is called. | 350 // Test that ProvisionalNavigationStarted() is called. |
351 ASSERT_FALSE(observer->did_finish_navigation_info()); | 351 ASSERT_FALSE(observer->did_finish_navigation_info()); |
352 const GURL url("http://test"); | 352 const GURL url("http://test"); |
353 std::unique_ptr<web::NavigationContext> context = | 353 std::unique_ptr<web::NavigationContext> context = |
354 NavigationContextImpl::CreateNavigationContext( | 354 NavigationContextImpl::CreateNavigationContext(web_state_.get(), url); |
355 web_state_.get(), url, nullptr /* response_headers */); | |
356 web_state_->OnNavigationFinished(context.get()); | 355 web_state_->OnNavigationFinished(context.get()); |
357 ASSERT_TRUE(observer->did_finish_navigation_info()); | 356 ASSERT_TRUE(observer->did_finish_navigation_info()); |
358 EXPECT_EQ(web_state_.get(), | 357 EXPECT_EQ(web_state_.get(), |
359 observer->did_finish_navigation_info()->web_state); | 358 observer->did_finish_navigation_info()->web_state); |
360 NavigationContext* actual_context = | 359 NavigationContext* actual_context = |
361 observer->did_finish_navigation_info()->context.get(); | 360 observer->did_finish_navigation_info()->context.get(); |
362 EXPECT_EQ(context->GetUrl(), actual_context->GetUrl()); | 361 EXPECT_EQ(context->GetUrl(), actual_context->GetUrl()); |
363 EXPECT_FALSE(actual_context->IsSameDocument()); | 362 EXPECT_FALSE(actual_context->IsSameDocument()); |
364 EXPECT_FALSE(actual_context->IsErrorPage()); | 363 EXPECT_FALSE(actual_context->IsErrorPage()); |
365 EXPECT_FALSE(actual_context->GetResponseHeaders()); | 364 EXPECT_FALSE(actual_context->GetResponseHeaders()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 ASSERT_FALSE(observer->load_page_info()); | 402 ASSERT_FALSE(observer->load_page_info()); |
404 web_state_->OnPageLoaded(url, false); | 403 web_state_->OnPageLoaded(url, false); |
405 ASSERT_TRUE(observer->load_page_info()); | 404 ASSERT_TRUE(observer->load_page_info()); |
406 EXPECT_EQ(web_state_.get(), observer->load_page_info()->web_state); | 405 EXPECT_EQ(web_state_.get(), observer->load_page_info()->web_state); |
407 EXPECT_FALSE(observer->load_page_info()->success); | 406 EXPECT_FALSE(observer->load_page_info()->success); |
408 web_state_->OnPageLoaded(url, true); | 407 web_state_->OnPageLoaded(url, true); |
409 ASSERT_TRUE(observer->load_page_info()); | 408 ASSERT_TRUE(observer->load_page_info()); |
410 EXPECT_EQ(web_state_.get(), observer->load_page_info()->web_state); | 409 EXPECT_EQ(web_state_.get(), observer->load_page_info()->web_state); |
411 EXPECT_TRUE(observer->load_page_info()->success); | 410 EXPECT_TRUE(observer->load_page_info()->success); |
412 | 411 |
413 // Reset the observer and test that DidFinishNavigation() is called | 412 // Test that OnTitleChanged() is called. |
414 // for same document navigations. | |
415 observer = base::MakeUnique<TestWebStateObserver>(web_state_.get()); | 413 observer = base::MakeUnique<TestWebStateObserver>(web_state_.get()); |
416 ASSERT_FALSE(observer->did_finish_navigation_info()); | |
417 web_state_->OnSameDocumentNavigation(url); | |
418 ASSERT_TRUE(observer->did_finish_navigation_info()); | |
419 EXPECT_EQ(web_state_.get(), | |
420 observer->did_finish_navigation_info()->web_state); | |
421 actual_context = observer->did_finish_navigation_info()->context.get(); | |
422 ASSERT_TRUE(actual_context); | |
423 EXPECT_EQ(url, actual_context->GetUrl()); | |
424 EXPECT_TRUE(actual_context->IsSameDocument()); | |
425 EXPECT_FALSE(actual_context->IsErrorPage()); | |
426 EXPECT_FALSE(actual_context->GetResponseHeaders()); | |
427 | |
428 // Reset the observer and test that DidFinishNavigation() is called | |
429 // for error navigations. | |
430 observer = base::MakeUnique<TestWebStateObserver>(web_state_.get()); | |
431 ASSERT_FALSE(observer->did_finish_navigation_info()); | |
432 web_state_->OnErrorPageNavigation(url); | |
433 ASSERT_TRUE(observer->did_finish_navigation_info()); | |
434 EXPECT_EQ(web_state_.get(), | |
435 observer->did_finish_navigation_info()->web_state); | |
436 actual_context = observer->did_finish_navigation_info()->context.get(); | |
437 ASSERT_TRUE(actual_context); | |
438 EXPECT_EQ(url, actual_context->GetUrl()); | |
439 EXPECT_FALSE(actual_context->IsSameDocument()); | |
440 EXPECT_TRUE(actual_context->IsErrorPage()); | |
441 EXPECT_FALSE(actual_context->GetResponseHeaders()); | |
442 | |
443 // Test that OnTitleChanged() is called. | |
444 ASSERT_FALSE(observer->title_was_set_info()); | 414 ASSERT_FALSE(observer->title_was_set_info()); |
445 web_state_->OnTitleChanged(); | 415 web_state_->OnTitleChanged(); |
446 ASSERT_TRUE(observer->title_was_set_info()); | 416 ASSERT_TRUE(observer->title_was_set_info()); |
447 EXPECT_EQ(web_state_.get(), observer->title_was_set_info()->web_state); | 417 EXPECT_EQ(web_state_.get(), observer->title_was_set_info()->web_state); |
448 | 418 |
449 // Test that WebStateDestroyed() is called. | 419 // Test that WebStateDestroyed() is called. |
450 EXPECT_FALSE(observer->web_state_destroyed_info()); | 420 EXPECT_FALSE(observer->web_state_destroyed_info()); |
451 web_state_.reset(); | 421 web_state_.reset(); |
452 EXPECT_TRUE(observer->web_state_destroyed_info()); | 422 EXPECT_TRUE(observer->web_state_destroyed_info()); |
453 | 423 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 // Set |created_with_opener| to true and verify that HasOpener() returns true. | 683 // Set |created_with_opener| to true and verify that HasOpener() returns true. |
714 WebState::CreateParams params_with_opener = | 684 WebState::CreateParams params_with_opener = |
715 WebState::CreateParams(GetBrowserState()); | 685 WebState::CreateParams(GetBrowserState()); |
716 params_with_opener.created_with_opener = true; | 686 params_with_opener.created_with_opener = true; |
717 std::unique_ptr<WebState> web_state_with_opener = | 687 std::unique_ptr<WebState> web_state_with_opener = |
718 WebState::Create(params_with_opener); | 688 WebState::Create(params_with_opener); |
719 EXPECT_TRUE(web_state_with_opener->HasOpener()); | 689 EXPECT_TRUE(web_state_with_opener->HasOpener()); |
720 } | 690 } |
721 | 691 |
722 } // namespace web | 692 } // namespace web |
OLD | NEW |