OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 | 6 |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/test/base/render_view_test.h" | 10 #include "chrome/test/base/render_view_test.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 int page_id_C; | 98 int page_id_C; |
99 std::string state_C; | 99 std::string state_C; |
100 ViewHostMsg_UpdateState::Read(msg_C, &page_id_C, &state_C); | 100 ViewHostMsg_UpdateState::Read(msg_C, &page_id_C, &state_C); |
101 EXPECT_EQ(3, page_id_C); | 101 EXPECT_EQ(3, page_id_C); |
102 EXPECT_NE(state_B, state_C); | 102 EXPECT_NE(state_B, state_C); |
103 render_thread_.sink().ClearMessages(); | 103 render_thread_.sink().ClearMessages(); |
104 | 104 |
105 // Go back to C and commit, preparing for our real test. | 105 // Go back to C and commit, preparing for our real test. |
106 ViewMsg_Navigate_Params params_C; | 106 ViewMsg_Navigate_Params params_C; |
107 params_C.navigation_type = ViewMsg_Navigate_Type::NORMAL; | 107 params_C.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
108 params_C.transition = PageTransition::FORWARD_BACK; | 108 params_C.transition = content::PAGE_TRANSITION_FORWARD_BACK; |
109 params_C.current_history_list_length = 4; | 109 params_C.current_history_list_length = 4; |
110 params_C.current_history_list_offset = 3; | 110 params_C.current_history_list_offset = 3; |
111 params_C.pending_history_list_offset = 2; | 111 params_C.pending_history_list_offset = 2; |
112 params_C.page_id = 3; | 112 params_C.page_id = 3; |
113 params_C.state = state_C; | 113 params_C.state = state_C; |
114 view()->OnNavigate(params_C); | 114 view()->OnNavigate(params_C); |
115 ProcessPendingMessages(); | 115 ProcessPendingMessages(); |
116 render_thread_.sink().ClearMessages(); | 116 render_thread_.sink().ClearMessages(); |
117 | 117 |
118 // Go back twice quickly, such that page B does not have a chance to commit. | 118 // Go back twice quickly, such that page B does not have a chance to commit. |
119 // This leads to two changes to the back/forward list but only one change to | 119 // This leads to two changes to the back/forward list but only one change to |
120 // the RenderView's page ID. | 120 // the RenderView's page ID. |
121 | 121 |
122 // Back to page B (page_id 2), without committing. | 122 // Back to page B (page_id 2), without committing. |
123 ViewMsg_Navigate_Params params_B; | 123 ViewMsg_Navigate_Params params_B; |
124 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; | 124 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
125 params_B.transition = PageTransition::FORWARD_BACK; | 125 params_B.transition = content::PAGE_TRANSITION_FORWARD_BACK; |
126 params_B.current_history_list_length = 4; | 126 params_B.current_history_list_length = 4; |
127 params_B.current_history_list_offset = 2; | 127 params_B.current_history_list_offset = 2; |
128 params_B.pending_history_list_offset = 1; | 128 params_B.pending_history_list_offset = 1; |
129 params_B.page_id = 2; | 129 params_B.page_id = 2; |
130 params_B.state = state_B; | 130 params_B.state = state_B; |
131 view()->OnNavigate(params_B); | 131 view()->OnNavigate(params_B); |
132 | 132 |
133 // Back to page A (page_id 1) and commit. | 133 // Back to page A (page_id 1) and commit. |
134 ViewMsg_Navigate_Params params; | 134 ViewMsg_Navigate_Params params; |
135 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; | 135 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
136 params.transition = PageTransition::FORWARD_BACK; | 136 params.transition = content::PAGE_TRANSITION_FORWARD_BACK; |
137 params_B.current_history_list_length = 4; | 137 params_B.current_history_list_length = 4; |
138 params_B.current_history_list_offset = 2; | 138 params_B.current_history_list_offset = 2; |
139 params_B.pending_history_list_offset = 0; | 139 params_B.pending_history_list_offset = 0; |
140 params.page_id = 1; | 140 params.page_id = 1; |
141 params.state = state_A; | 141 params.state = state_A; |
142 view()->OnNavigate(params); | 142 view()->OnNavigate(params); |
143 ProcessPendingMessages(); | 143 ProcessPendingMessages(); |
144 | 144 |
145 // Now ensure that the UpdateState message we receive is consistent | 145 // Now ensure that the UpdateState message we receive is consistent |
146 // and represents page C in both page_id and state. | 146 // and represents page C in both page_id and state. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 ASSERT_TRUE(msg_A); | 178 ASSERT_TRUE(msg_A); |
179 int page_id_A; | 179 int page_id_A; |
180 std::string state_A; | 180 std::string state_A; |
181 ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A); | 181 ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A); |
182 EXPECT_EQ(1, page_id_A); | 182 EXPECT_EQ(1, page_id_A); |
183 render_thread_.sink().ClearMessages(); | 183 render_thread_.sink().ClearMessages(); |
184 | 184 |
185 // Back to page A (page_id 1) and commit. | 185 // Back to page A (page_id 1) and commit. |
186 ViewMsg_Navigate_Params params_A; | 186 ViewMsg_Navigate_Params params_A; |
187 params_A.navigation_type = ViewMsg_Navigate_Type::NORMAL; | 187 params_A.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
188 params_A.transition = PageTransition::FORWARD_BACK; | 188 params_A.transition = content::PAGE_TRANSITION_FORWARD_BACK; |
189 params_A.current_history_list_length = 2; | 189 params_A.current_history_list_length = 2; |
190 params_A.current_history_list_offset = 1; | 190 params_A.current_history_list_offset = 1; |
191 params_A.pending_history_list_offset = 0; | 191 params_A.pending_history_list_offset = 0; |
192 params_A.page_id = 1; | 192 params_A.page_id = 1; |
193 params_A.state = state_A; | 193 params_A.state = state_A; |
194 view()->OnNavigate(params_A); | 194 view()->OnNavigate(params_A); |
195 ProcessPendingMessages(); | 195 ProcessPendingMessages(); |
196 | 196 |
197 // A new navigation commits, clearing the forward history. | 197 // A new navigation commits, clearing the forward history. |
198 LoadHTML("<div>Page C</div>"); | 198 LoadHTML("<div>Page C</div>"); |
199 EXPECT_EQ(2, view()->history_list_length_); | 199 EXPECT_EQ(2, view()->history_list_length_); |
200 EXPECT_EQ(1, view()->history_list_offset_); | 200 EXPECT_EQ(1, view()->history_list_offset_); |
201 EXPECT_EQ(3, view()->history_page_ids_[1]); | 201 EXPECT_EQ(3, view()->history_page_ids_[1]); |
202 | 202 |
203 // The browser then sends a stale navigation to B, which should be ignored. | 203 // The browser then sends a stale navigation to B, which should be ignored. |
204 ViewMsg_Navigate_Params params_B; | 204 ViewMsg_Navigate_Params params_B; |
205 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; | 205 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
206 params_B.transition = PageTransition::FORWARD_BACK; | 206 params_B.transition = content::PAGE_TRANSITION_FORWARD_BACK; |
207 params_B.current_history_list_length = 2; | 207 params_B.current_history_list_length = 2; |
208 params_B.current_history_list_offset = 0; | 208 params_B.current_history_list_offset = 0; |
209 params_B.pending_history_list_offset = 1; | 209 params_B.pending_history_list_offset = 1; |
210 params_B.page_id = 2; | 210 params_B.page_id = 2; |
211 params_B.state = state_A; // Doesn't matter, just has to be present. | 211 params_B.state = state_A; // Doesn't matter, just has to be present. |
212 view()->OnNavigate(params_B); | 212 view()->OnNavigate(params_B); |
213 | 213 |
214 // State should be unchanged. | 214 // State should be unchanged. |
215 EXPECT_EQ(2, view()->history_list_length_); | 215 EXPECT_EQ(2, view()->history_list_length_); |
216 EXPECT_EQ(1, view()->history_list_offset_); | 216 EXPECT_EQ(1, view()->history_list_offset_); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 std::string state_B; | 260 std::string state_B; |
261 ViewHostMsg_UpdateState::Read(msg_B, &page_id_B, &state_B); | 261 ViewHostMsg_UpdateState::Read(msg_B, &page_id_B, &state_B); |
262 EXPECT_EQ(2, page_id_B); | 262 EXPECT_EQ(2, page_id_B); |
263 render_thread_.sink().ClearMessages(); | 263 render_thread_.sink().ClearMessages(); |
264 | 264 |
265 // Suppose the browser has limited the number of NavigationEntries to 2. | 265 // Suppose the browser has limited the number of NavigationEntries to 2. |
266 // It has now dropped the first entry, but the renderer isn't notified. | 266 // It has now dropped the first entry, but the renderer isn't notified. |
267 // Ensure that going back to page B (page_id 2) at offset 0 is successful. | 267 // Ensure that going back to page B (page_id 2) at offset 0 is successful. |
268 ViewMsg_Navigate_Params params_B; | 268 ViewMsg_Navigate_Params params_B; |
269 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; | 269 params_B.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
270 params_B.transition = PageTransition::FORWARD_BACK; | 270 params_B.transition = content::PAGE_TRANSITION_FORWARD_BACK; |
271 params_B.current_history_list_length = 2; | 271 params_B.current_history_list_length = 2; |
272 params_B.current_history_list_offset = 1; | 272 params_B.current_history_list_offset = 1; |
273 params_B.pending_history_list_offset = 0; | 273 params_B.pending_history_list_offset = 0; |
274 params_B.page_id = 2; | 274 params_B.page_id = 2; |
275 params_B.state = state_B; | 275 params_B.state = state_B; |
276 view()->OnNavigate(params_B); | 276 view()->OnNavigate(params_B); |
277 ProcessPendingMessages(); | 277 ProcessPendingMessages(); |
278 | 278 |
279 EXPECT_EQ(2, view()->history_list_length_); | 279 EXPECT_EQ(2, view()->history_list_length_); |
280 EXPECT_EQ(0, view()->history_list_offset_); | 280 EXPECT_EQ(0, view()->history_list_offset_); |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 expected_page_id_2 = view()->page_id_; | 1078 expected_page_id_2 = view()->page_id_; |
1079 EXPECT_GT(expected_page_id_2, expected_page_id); | 1079 EXPECT_GT(expected_page_id_2, expected_page_id); |
1080 view()->OnSetHistoryLengthAndPrune(2, -1); | 1080 view()->OnSetHistoryLengthAndPrune(2, -1); |
1081 EXPECT_EQ(4, view()->history_list_length_); | 1081 EXPECT_EQ(4, view()->history_list_length_); |
1082 EXPECT_EQ(3, view()->history_list_offset_); | 1082 EXPECT_EQ(3, view()->history_list_offset_); |
1083 EXPECT_EQ(-1, view()->history_page_ids_[0]); | 1083 EXPECT_EQ(-1, view()->history_page_ids_[0]); |
1084 EXPECT_EQ(-1, view()->history_page_ids_[1]); | 1084 EXPECT_EQ(-1, view()->history_page_ids_[1]); |
1085 EXPECT_EQ(expected_page_id, view()->history_page_ids_[2]); | 1085 EXPECT_EQ(expected_page_id, view()->history_page_ids_[2]); |
1086 EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[3]); | 1086 EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[3]); |
1087 } | 1087 } |
OLD | NEW |