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

Side by Side Diff: ios/web/navigation/navigation_manager_impl_unittest.mm

Issue 2491773005: [ios] Removed canGoBack/canGoForward API from CRWSessionController. (Closed)
Patch Set: Fixed compilation. Created 4 years, 1 month 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
« no previous file with comments | « ios/web/navigation/navigation_manager_impl.mm ('k') | ios/web/public/navigation_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/navigation/navigation_manager_impl.h" 5 #import "ios/web/navigation/navigation_manager_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/scoped_nsobject.h" 8 #import "base/mac/scoped_nsobject.h"
9 #import "ios/web/navigation/crw_session_controller+private_constructors.h" 9 #import "ios/web/navigation/crw_session_controller+private_constructors.h"
10 #import "ios/web/navigation/navigation_manager_delegate.h" 10 #import "ios/web/navigation/navigation_manager_delegate.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 referrer:Referrer() 86 referrer:Referrer()
87 transition:ui::PAGE_TRANSITION_TYPED 87 transition:ui::PAGE_TRANSITION_TYPED
88 rendererInitiated:NO]; 88 rendererInitiated:NO];
89 [session_controller() commitPendingEntry]; 89 [session_controller() commitPendingEntry];
90 90
91 EXPECT_EQ(-1, navigation_manager()->GetPendingItemIndex()); 91 EXPECT_EQ(-1, navigation_manager()->GetPendingItemIndex());
92 [session_controller() setPendingEntryIndex:0]; 92 [session_controller() setPendingEntryIndex:0];
93 EXPECT_EQ(0, navigation_manager()->GetPendingItemIndex()); 93 EXPECT_EQ(0, navigation_manager()->GetPendingItemIndex());
94 } 94 }
95 95
96 // Tests that going back or negative offset is not possible without a committed
97 // item.
98 TEST_F(NavigationManagerTest, CanGoBackWithoutCommitedItem) {
99 EXPECT_FALSE(navigation_manager()->CanGoBack());
100 EXPECT_FALSE(navigation_manager()->CanGoToOffset(-1));
101 }
102
103 // Tests that going back or negative offset is not possible if there is a
104 // transient item, but not committed items.
105 TEST_F(NavigationManagerTest, CanGoBackWithTransientItem) {
106 [session_controller() addTransientEntryWithURL:GURL("http://www.url.com")];
107
108 EXPECT_FALSE(navigation_manager()->CanGoBack());
109 EXPECT_FALSE(navigation_manager()->CanGoToOffset(-1));
110 }
111
112 // Tests that going back or negative offset is possible if there is a transient
113 // item and at least one committed item.
114 TEST_F(NavigationManagerTest, CanGoBackWithTransientItemAndCommittedItem) {
115 [session_controller() addPendingEntry:GURL("http://www.url.com")
116 referrer:Referrer()
117 transition:ui::PAGE_TRANSITION_TYPED
118 rendererInitiated:NO];
119 [session_controller() commitPendingEntry];
120 [session_controller() addTransientEntryWithURL:GURL("http://www.url.com/0")];
121
122 EXPECT_TRUE(navigation_manager()->CanGoBack());
123 EXPECT_TRUE(navigation_manager()->CanGoToOffset(-1));
124 }
125
126 // Tests that going back or negative offset is not possible if there is ony one
127 // committed item and no transient item.
128 TEST_F(NavigationManagerTest, CanGoBackWithSingleCommitedItem) {
129 [session_controller() addPendingEntry:GURL("http://www.url.com")
130 referrer:Referrer()
131 transition:ui::PAGE_TRANSITION_TYPED
132 rendererInitiated:NO];
133 [session_controller() commitPendingEntry];
134
135 EXPECT_FALSE(navigation_manager()->CanGoBack());
136 EXPECT_FALSE(navigation_manager()->CanGoToOffset(-1));
137 }
138
139 // Tests going back possibility with multiple committed items.
140 TEST_F(NavigationManagerTest, CanGoBackWithMultipleCommitedItems) {
141 [session_controller() addPendingEntry:GURL("http://www.url.com")
142 referrer:Referrer()
143 transition:ui::PAGE_TRANSITION_TYPED
144 rendererInitiated:NO];
145 [session_controller() commitPendingEntry];
146 [session_controller() addPendingEntry:GURL("http://www.url.com/0")
147 referrer:Referrer()
148 transition:ui::PAGE_TRANSITION_TYPED
149 rendererInitiated:NO];
150 [session_controller() commitPendingEntry];
151 [session_controller() addPendingEntry:GURL("http://www.url.com/1")
152 referrer:Referrer()
153 transition:ui::PAGE_TRANSITION_TYPED
154 rendererInitiated:NO];
155 [session_controller() commitPendingEntry];
156
157 EXPECT_TRUE(navigation_manager()->CanGoBack());
158 EXPECT_TRUE(navigation_manager()->CanGoToOffset(-1));
159
160 [session_controller() goToEntry:session_controller().entries[1]];
161 EXPECT_TRUE(navigation_manager()->CanGoBack());
162 EXPECT_TRUE(navigation_manager()->CanGoToOffset(-1));
163
164 [session_controller() goToEntry:session_controller().entries[0]];
165 EXPECT_FALSE(navigation_manager()->CanGoBack());
166 EXPECT_FALSE(navigation_manager()->CanGoToOffset(-1));
167
168 [session_controller() goToEntry:session_controller().entries[1]];
169 EXPECT_TRUE(navigation_manager()->CanGoBack());
170 EXPECT_TRUE(navigation_manager()->CanGoToOffset(-1));
171 }
172
173 // Tests that going forward or positive offset is not possible if there is a
174 // pending entry.
175 TEST_F(NavigationManagerTest, CanGoForwardWithPendingItem) {
176 [session_controller() addPendingEntry:GURL("http://www.url.com")
177 referrer:Referrer()
178 transition:ui::PAGE_TRANSITION_TYPED
179 rendererInitiated:NO];
180 [session_controller() commitPendingEntry];
181 [session_controller() addPendingEntry:GURL("http://www.url.com/0")
182 referrer:Referrer()
183 transition:ui::PAGE_TRANSITION_TYPED
184 rendererInitiated:NO];
185 [session_controller() commitPendingEntry];
186 [session_controller() goToEntry:session_controller().entries[0]];
187 [session_controller() addPendingEntry:GURL("http://www.url.com/1")
188 referrer:Referrer()
189 transition:ui::PAGE_TRANSITION_TYPED
190 rendererInitiated:NO];
191
192 // Pending entry should not allow going forward.
193 EXPECT_FALSE(navigation_manager()->CanGoForward());
194 EXPECT_FALSE(navigation_manager()->CanGoToOffset(1));
195 }
196
197 // Tests that going forward or positive offset is not possible without a
198 // committed item.
199 TEST_F(NavigationManagerTest, CanGoForwardWithoutCommitedItem) {
200 EXPECT_FALSE(navigation_manager()->CanGoForward());
201 EXPECT_FALSE(navigation_manager()->CanGoToOffset(1));
202 }
203
204 // Tests that going forward or positive offset is not possible if there is ony
205 // one committed item and no transient item.
206 TEST_F(NavigationManagerTest, CanGoForwardWithSingleCommitedItem) {
207 [session_controller() addPendingEntry:GURL("http://www.url.com")
208 referrer:Referrer()
209 transition:ui::PAGE_TRANSITION_TYPED
210 rendererInitiated:NO];
211 [session_controller() commitPendingEntry];
212
213 EXPECT_FALSE(navigation_manager()->CanGoForward());
214 EXPECT_FALSE(navigation_manager()->CanGoToOffset(1));
215 }
216
217 // Tests going forward possibility with multiple committed items.
218 TEST_F(NavigationManagerTest, CanGoForwardWithMultipleCommitedEntries) {
219 [session_controller() addPendingEntry:GURL("http://www.url.com")
220 referrer:Referrer()
221 transition:ui::PAGE_TRANSITION_TYPED
222 rendererInitiated:NO];
223 [session_controller() commitPendingEntry];
224 [session_controller() addPendingEntry:GURL("http://www.url.com/0")
225 referrer:Referrer()
226 transition:ui::PAGE_TRANSITION_TYPED
227 rendererInitiated:NO];
228 [session_controller() commitPendingEntry];
229 [session_controller() addPendingEntry:GURL("http://www.url.com/1")
230 referrer:Referrer()
231 transition:ui::PAGE_TRANSITION_TYPED
232 rendererInitiated:NO];
233 [session_controller() commitPendingEntry];
234
235 EXPECT_FALSE(navigation_manager()->CanGoForward());
236 EXPECT_FALSE(navigation_manager()->CanGoToOffset(1));
237
238 [session_controller() goToEntry:session_controller().entries[1]];
239 EXPECT_TRUE(navigation_manager()->CanGoForward());
240 EXPECT_TRUE(navigation_manager()->CanGoToOffset(1));
241
242 [session_controller() goToEntry:session_controller().entries[0]];
243 EXPECT_TRUE(navigation_manager()->CanGoForward());
244 EXPECT_TRUE(navigation_manager()->CanGoToOffset(1));
245
246 [session_controller() goToEntry:session_controller().entries[1]];
247 EXPECT_TRUE(navigation_manager()->CanGoForward());
248 EXPECT_TRUE(navigation_manager()->CanGoToOffset(1));
249
250 [session_controller() goToEntry:session_controller().entries[2]];
251 EXPECT_FALSE(navigation_manager()->CanGoForward());
252 EXPECT_FALSE(navigation_manager()->CanGoToOffset(1));
253 }
254
96 } // namespace web 255 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/navigation/navigation_manager_impl.mm ('k') | ios/web/public/navigation_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698