OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/public/test/fakes/test_web_state_observer.h" | 5 #include "ios/web/public/test/fakes/test_web_state_observer.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "ios/web/public/web_state/navigation_context.h" | 8 #import "ios/web/public/web_state/navigation_context.h" |
9 #include "ios/web/public/web_state/web_state.h" | 9 #include "ios/web/public/web_state/web_state.h" |
10 #include "ios/web/web_state/navigation_context_impl.h" | 10 #include "ios/web/web_state/navigation_context_impl.h" |
11 #include "net/http/http_response_headers.h" | 11 #include "net/http/http_response_headers.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace web { | 14 namespace web { |
15 | 15 |
16 TestWebStateObserver::TestWebStateObserver(WebState* web_state) | 16 TestWebStateObserver::TestWebStateObserver(WebState* web_state) |
17 : WebStateObserver(web_state) {} | 17 : WebStateObserver(web_state) {} |
18 TestWebStateObserver::~TestWebStateObserver() = default; | 18 TestWebStateObserver::~TestWebStateObserver() = default; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 navigation_items_pruned_info_->count = pruned_item_count; | 52 navigation_items_pruned_info_->count = pruned_item_count; |
53 } | 53 } |
54 | 54 |
55 void TestWebStateObserver::NavigationItemChanged() { | 55 void TestWebStateObserver::NavigationItemChanged() { |
56 navigation_item_changed_info_ = | 56 navigation_item_changed_info_ = |
57 base::MakeUnique<web::TestNavigationItemChangedInfo>(); | 57 base::MakeUnique<web::TestNavigationItemChangedInfo>(); |
58 navigation_item_changed_info_->web_state = web_state(); | 58 navigation_item_changed_info_->web_state = web_state(); |
59 } | 59 } |
60 | 60 |
61 void TestWebStateObserver::DidStartNavigation(NavigationContext* navigation) { | 61 void TestWebStateObserver::DidStartNavigation(NavigationContext* navigation) { |
62 ASSERT_TRUE(!navigation->IsErrorPage() || !navigation->IsSameDocument()); | 62 ASSERT_TRUE(!navigation->GetError() || !navigation->IsSameDocument()); |
63 did_start_navigation_info_ = | 63 did_start_navigation_info_ = |
64 base::MakeUnique<web::TestDidStartNavigationInfo>(); | 64 base::MakeUnique<web::TestDidStartNavigationInfo>(); |
65 did_start_navigation_info_->web_state = web_state(); | 65 did_start_navigation_info_->web_state = web_state(); |
66 std::unique_ptr<web::NavigationContextImpl> context = | 66 std::unique_ptr<web::NavigationContextImpl> context = |
67 web::NavigationContextImpl::CreateNavigationContext( | 67 web::NavigationContextImpl::CreateNavigationContext( |
68 navigation->GetWebState(), navigation->GetUrl()); | 68 navigation->GetWebState(), navigation->GetUrl()); |
69 context->SetIsSameDocument(navigation->IsSameDocument()); | 69 context->SetIsSameDocument(navigation->IsSameDocument()); |
70 context->SetIsErrorPage(navigation->IsErrorPage()); | 70 context->SetError(navigation->GetError()); |
71 did_start_navigation_info_->context = std::move(context); | 71 did_start_navigation_info_->context = std::move(context); |
72 } | 72 } |
73 | 73 |
74 void TestWebStateObserver::DidFinishNavigation(NavigationContext* navigation) { | 74 void TestWebStateObserver::DidFinishNavigation(NavigationContext* navigation) { |
75 ASSERT_TRUE(!navigation->IsErrorPage() || !navigation->IsSameDocument()); | 75 ASSERT_TRUE(!navigation->GetError() || !navigation->IsSameDocument()); |
76 did_finish_navigation_info_ = | 76 did_finish_navigation_info_ = |
77 base::MakeUnique<web::TestDidFinishNavigationInfo>(); | 77 base::MakeUnique<web::TestDidFinishNavigationInfo>(); |
78 did_finish_navigation_info_->web_state = web_state(); | 78 did_finish_navigation_info_->web_state = web_state(); |
79 std::unique_ptr<web::NavigationContextImpl> context = | 79 std::unique_ptr<web::NavigationContextImpl> context = |
80 web::NavigationContextImpl::CreateNavigationContext( | 80 web::NavigationContextImpl::CreateNavigationContext( |
81 navigation->GetWebState(), navigation->GetUrl()); | 81 navigation->GetWebState(), navigation->GetUrl()); |
82 context->SetIsSameDocument(navigation->IsSameDocument()); | 82 context->SetIsSameDocument(navigation->IsSameDocument()); |
83 context->SetIsErrorPage(navigation->IsErrorPage()); | 83 context->SetError(navigation->GetError()); |
84 did_finish_navigation_info_->context = std::move(context); | 84 did_finish_navigation_info_->context = std::move(context); |
85 } | 85 } |
86 | 86 |
87 void TestWebStateObserver::TitleWasSet() { | 87 void TestWebStateObserver::TitleWasSet() { |
88 title_was_set_info_ = base::MakeUnique<web::TestTitleWasSetInfo>(); | 88 title_was_set_info_ = base::MakeUnique<web::TestTitleWasSetInfo>(); |
89 title_was_set_info_->web_state = web_state(); | 89 title_was_set_info_->web_state = web_state(); |
90 } | 90 } |
91 | 91 |
92 void TestWebStateObserver::DidChangeVisibleSecurityState() { | 92 void TestWebStateObserver::DidChangeVisibleSecurityState() { |
93 did_change_visible_security_state_info_ = | 93 did_change_visible_security_state_info_ = |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 start_loading_info_ = base::MakeUnique<web::TestStartLoadingInfo>(); | 149 start_loading_info_ = base::MakeUnique<web::TestStartLoadingInfo>(); |
150 start_loading_info_->web_state = web_state(); | 150 start_loading_info_->web_state = web_state(); |
151 } | 151 } |
152 | 152 |
153 void TestWebStateObserver::DidStopLoading() { | 153 void TestWebStateObserver::DidStopLoading() { |
154 stop_loading_info_ = base::MakeUnique<web::TestStopLoadingInfo>(); | 154 stop_loading_info_ = base::MakeUnique<web::TestStopLoadingInfo>(); |
155 stop_loading_info_->web_state = web_state(); | 155 stop_loading_info_->web_state = web_state(); |
156 } | 156 } |
157 | 157 |
158 } // namespace web | 158 } // namespace web |
OLD | NEW |