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

Side by Side Diff: ios/web/public/test/fakes/test_web_state_observer.mm

Issue 2724953004: Test actual arguments in WebStateImplTest::ObserverTest. (Closed)
Patch Set: Rebased Created 3 years, 9 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 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"
8 #include "ios/web/public/web_state/navigation_context.h"
7 #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"
8 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
9 12
10 namespace web { 13 namespace web {
11 14
12 void TestWebStateObserver::ProvisionalNavigationStarted(const GURL&) { 15 TestWebStateObserver::TestWebStateObserver(WebState* web_state)
13 provisional_navigation_started_called_ = true; 16 : WebStateObserver(web_state) {}
14 } 17 TestWebStateObserver::~TestWebStateObserver() = default;
15 18
16 void TestWebStateObserver::NavigationItemsPruned(size_t) { 19 void TestWebStateObserver::ProvisionalNavigationStarted(const GURL& url) {
17 navigation_items_pruned_called_ = true; 20 start_provisional_navigation_info_ =
18 } 21 base::MakeUnique<web::TestStartProvisionalNavigationInfo>();
19 22 start_provisional_navigation_info_->web_state = web_state();
20 void TestWebStateObserver::NavigationItemChanged() { 23 start_provisional_navigation_info_->url = url;
21 navigation_item_changed_called_ = true;
22 } 24 }
23 25
24 void TestWebStateObserver::NavigationItemCommitted( 26 void TestWebStateObserver::NavigationItemCommitted(
25 const LoadCommittedDetails& load_details) { 27 const LoadCommittedDetails& load_details) {
26 navigation_item_committed_called_ = true; 28 commit_navigation_info_ = base::MakeUnique<web::TestCommitNavigationInfo>();
29 commit_navigation_info_->web_state = web_state();
30 commit_navigation_info_->load_details = load_details;
27 } 31 }
28 32
29 void TestWebStateObserver::DidFinishNavigation(NavigationContext*) { 33 void TestWebStateObserver::PageLoaded(
30 did_finish_navigation_called_ = true; 34 PageLoadCompletionStatus load_completion_status) {
35 load_page_info_ = base::MakeUnique<web::TestLoadPageInfo>();
36 load_page_info_->web_state = web_state();
37 load_page_info_->success =
38 load_completion_status == PageLoadCompletionStatus::SUCCESS;
31 } 39 }
32 40
33 void TestWebStateObserver::PageLoaded(PageLoadCompletionStatus status) { 41 void TestWebStateObserver::InterstitialDismissed() {
34 page_loaded_called_with_success_ = 42 dismiss_interstitial_info_ =
35 status == PageLoadCompletionStatus::SUCCESS; 43 base::MakeUnique<web::TestDismissInterstitialInfo>();
44 dismiss_interstitial_info_->web_state = web_state();
45 }
46
47 void TestWebStateObserver::LoadProgressChanged(double progress) {
48 change_loading_progress_info_ =
49 base::MakeUnique<web::TestChangeLoadingProgressInfo>();
50 change_loading_progress_info_->web_state = web_state();
51 change_loading_progress_info_->progress = progress;
52 }
53
54 void TestWebStateObserver::NavigationItemsPruned(size_t pruned_item_count) {
55 navigation_items_pruned_info_ =
56 base::MakeUnique<web::TestNavigationItemsPrunedInfo>();
57 navigation_items_pruned_info_->web_state = web_state();
58 navigation_items_pruned_info_->count = pruned_item_count;
59 }
60
61 void TestWebStateObserver::NavigationItemChanged() {
62 navigation_item_changed_info_ =
63 base::MakeUnique<web::TestNavigationItemChangedInfo>();
64 navigation_item_changed_info_->web_state = web_state();
65 }
66
67 void TestWebStateObserver::DidFinishNavigation(NavigationContext* context) {
68 did_finish_navigation_info_ =
69 base::MakeUnique<web::TestDidFinishNavigationInfo>();
70 did_finish_navigation_info_->web_state = web_state();
71 if (context->IsSamePage()) {
72 ASSERT_FALSE(context->IsErrorPage());
73 did_finish_navigation_info_->context =
74 NavigationContextImpl::CreateSamePageNavigationContext(
75 context->GetWebState(), context->GetUrl());
76 } else if (context->IsErrorPage()) {
77 ASSERT_FALSE(context->IsSamePage());
78 did_finish_navigation_info_->context =
79 NavigationContextImpl::CreateErrorPageNavigationContext(
80 context->GetWebState(), context->GetUrl());
81 } else {
82 did_finish_navigation_info_->context =
83 NavigationContextImpl::CreateNavigationContext(context->GetWebState(),
84 context->GetUrl());
85 }
36 } 86 }
37 87
38 void TestWebStateObserver::TitleWasSet() { 88 void TestWebStateObserver::TitleWasSet() {
39 title_was_set_called_ = true; 89 title_was_set_info_ = base::MakeUnique<web::TestTitleWasSetInfo>();
90 title_was_set_info_->web_state = web_state();
91 }
92
93 void TestWebStateObserver::DocumentSubmitted(const std::string& form_name,
94 bool user_initiated) {
95 submit_document_info_ = base::MakeUnique<web::TestSubmitDocumentInfo>();
96 submit_document_info_->web_state = web_state();
97 submit_document_info_->form_name = form_name;
98 submit_document_info_->user_initiated = user_initiated;
99 }
100
101 void TestWebStateObserver::FormActivityRegistered(const std::string& form_name,
102 const std::string& field_name,
103 const std::string& type,
104 const std::string& value,
105 bool input_missing) {
106 form_activity_info_ = base::MakeUnique<web::TestFormActivityInfo>();
107 form_activity_info_->web_state = web_state();
108 form_activity_info_->form_name = form_name;
109 form_activity_info_->field_name = field_name;
110 form_activity_info_->type = type;
111 form_activity_info_->value = value;
112 form_activity_info_->input_missing = input_missing;
113 }
114
115 void TestWebStateObserver::FaviconUrlUpdated(
116 const std::vector<FaviconURL>& candidates) {
117 update_favicon_url_candidates_info_ =
118 base::MakeUnique<web::TestUpdateFaviconUrlCandidatesInfo>();
119 update_favicon_url_candidates_info_->web_state = web_state();
120 update_favicon_url_candidates_info_->candidates = candidates;
121 }
122
123 void TestWebStateObserver::RenderProcessGone() {
124 render_process_gone_info_ =
125 base::MakeUnique<web::TestRenderProcessGoneInfo>();
126 render_process_gone_info_->web_state = web_state();
40 } 127 }
41 128
42 void TestWebStateObserver::WebStateDestroyed() { 129 void TestWebStateObserver::WebStateDestroyed() {
43 EXPECT_TRUE(web_state()->IsBeingDestroyed()); 130 EXPECT_TRUE(web_state()->IsBeingDestroyed());
44 web_state_destroyed_called_ = true; 131 web_state_destroyed_info_ =
132 base::MakeUnique<web::TestWebStateDestroyedInfo>();
133 web_state_destroyed_info_->web_state = web_state();
45 Observe(nullptr); 134 Observe(nullptr);
46 } 135 }
47 136
137 void TestWebStateObserver::DidStartLoading() {
138 start_loading_info_ = base::MakeUnique<web::TestStartLoadingInfo>();
139 start_loading_info_->web_state = web_state();
140 }
141
142 void TestWebStateObserver::DidStopLoading() {
143 stop_loading_info_ = base::MakeUnique<web::TestStopLoadingInfo>();
144 stop_loading_info_->web_state = web_state();
145 }
146
48 } // namespace web 147 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698