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