| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #import "ios/web/public/navigation_item.h" | 10 #import "ios/web/public/navigation_item.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ACTION_P3(VerifyPostStartedContext, web_state, url, context) { | 80 ACTION_P3(VerifyPostStartedContext, web_state, url, context) { |
| 81 *context = arg0; | 81 *context = arg0; |
| 82 ASSERT_TRUE(*context); | 82 ASSERT_TRUE(*context); |
| 83 EXPECT_EQ(web_state, (*context)->GetWebState()); | 83 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 84 EXPECT_EQ(url, (*context)->GetUrl()); | 84 EXPECT_EQ(url, (*context)->GetUrl()); |
| 85 EXPECT_FALSE((*context)->IsSameDocument()); | 85 EXPECT_FALSE((*context)->IsSameDocument()); |
| 86 EXPECT_TRUE((*context)->IsPost()); | 86 EXPECT_TRUE((*context)->IsPost()); |
| 87 EXPECT_FALSE((*context)->GetError()); | 87 EXPECT_FALSE((*context)->GetError()); |
| 88 ASSERT_FALSE((*context)->GetResponseHeaders()); | 88 ASSERT_FALSE((*context)->GetResponseHeaders()); |
| 89 ASSERT_TRUE(web_state->IsLoading()); | 89 ASSERT_TRUE(web_state->IsLoading()); |
| 90 NavigationManager* navigation_manager = web_state->GetNavigationManager(); | 90 // TODO(crbug.com/676129): Reload does not create a pending item. Remove this |
| 91 NavigationItem* item = navigation_manager->GetPendingItem(); | 91 // workaround once the bug is fixed. |
| 92 EXPECT_EQ(url, item->GetURL()); | 92 if (!ui::PageTransitionTypeIncludingQualifiersIs( |
| 93 ui::PageTransition::PAGE_TRANSITION_RELOAD, |
| 94 (*context)->GetPageTransition())) { |
| 95 NavigationManager* navigation_manager = web_state->GetNavigationManager(); |
| 96 NavigationItem* item = navigation_manager->GetPendingItem(); |
| 97 EXPECT_EQ(url, item->GetURL()); |
| 98 } |
| 93 } | 99 } |
| 94 | 100 |
| 95 // Verifies correctness of |NavigationContext| (|arg0|) for navigations via POST | 101 // Verifies correctness of |NavigationContext| (|arg0|) for navigations via POST |
| 96 // HTTP methods passed to |DidFinishNavigation|. Stores |NavigationContext| in | 102 // HTTP methods passed to |DidFinishNavigation|. Stores |NavigationContext| in |
| 97 // |context| pointer. | 103 // |context| pointer. |
| 98 ACTION_P3(VerifyPostFinishedContext, web_state, url, context) { | 104 ACTION_P3(VerifyPostFinishedContext, web_state, url, context) { |
| 99 ASSERT_EQ(*context, arg0); | 105 ASSERT_EQ(*context, arg0); |
| 100 EXPECT_EQ(web_state, (*context)->GetWebState()); | 106 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 101 ASSERT_TRUE((*context)); | 107 ASSERT_TRUE((*context)); |
| 102 EXPECT_EQ(web_state, (*context)->GetWebState()); | 108 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 *context = arg0; | 210 *context = arg0; |
| 205 ASSERT_TRUE(*context); | 211 ASSERT_TRUE(*context); |
| 206 EXPECT_EQ(web_state, (*context)->GetWebState()); | 212 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 207 EXPECT_EQ(url, (*context)->GetUrl()); | 213 EXPECT_EQ(url, (*context)->GetUrl()); |
| 208 EXPECT_TRUE( | 214 EXPECT_TRUE( |
| 209 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_RELOAD, | 215 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_RELOAD, |
| 210 (*context)->GetPageTransition())); | 216 (*context)->GetPageTransition())); |
| 211 EXPECT_FALSE((*context)->IsSameDocument()); | 217 EXPECT_FALSE((*context)->IsSameDocument()); |
| 212 EXPECT_FALSE((*context)->GetError()); | 218 EXPECT_FALSE((*context)->GetError()); |
| 213 EXPECT_FALSE((*context)->GetResponseHeaders()); | 219 EXPECT_FALSE((*context)->GetResponseHeaders()); |
| 214 EXPECT_EQ(web_state->GetNavigationManager()->GetPendingItem(), | 220 // TODO(crbug.com/676129): Reload does not create a pending item. Check |
| 215 web_state->GetNavigationManager()->GetLastCommittedItem()); | 221 // pending item once the bug is fixed. |
| 222 EXPECT_FALSE(web_state->GetNavigationManager()->GetPendingItem()); |
| 216 } | 223 } |
| 217 | 224 |
| 218 // Verifies correctness of |NavigationContext| (|arg0|) for reload navigation | 225 // Verifies correctness of |NavigationContext| (|arg0|) for reload navigation |
| 219 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as | 226 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as |
| 220 // |context|. | 227 // |context|. |
| 221 ACTION_P4(VerifyReloadFinishedContext, web_state, url, context, is_web_page) { | 228 ACTION_P4(VerifyReloadFinishedContext, web_state, url, context, is_web_page) { |
| 222 ASSERT_EQ(*context, arg0); | 229 ASSERT_EQ(*context, arg0); |
| 223 ASSERT_TRUE(*context); | 230 ASSERT_TRUE(*context); |
| 224 EXPECT_EQ(web_state, (*context)->GetWebState()); | 231 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 225 EXPECT_EQ(url, (*context)->GetUrl()); | 232 EXPECT_EQ(url, (*context)->GetUrl()); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing | 643 // delegate does not run callback for ShowRepostFormWarningDialog. Clearing |
| 637 // the delegate will allow form resubmission. Remove this workaround (clearing | 644 // the delegate will allow form resubmission. Remove this workaround (clearing |
| 638 // the delegate, once |check_for_repost| is supported). | 645 // the delegate, once |check_for_repost| is supported). |
| 639 web_state()->SetDelegate(nullptr); | 646 web_state()->SetDelegate(nullptr); |
| 640 ExecuteBlockAndWaitForLoad(action, ^{ | 647 ExecuteBlockAndWaitForLoad(action, ^{ |
| 641 navigation_manager()->GoForward(); | 648 navigation_manager()->GoForward(); |
| 642 }); | 649 }); |
| 643 } | 650 } |
| 644 | 651 |
| 645 } // namespace web | 652 } // namespace web |
| OLD | NEW |