| 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 #import "ios/web/public/web_state/web_state.h" | 5 #import "ios/web/public/web_state/web_state.h" |
| 6 | 6 |
| 7 #include "base/mac/bind_objc_block.h" | 7 #include "base/mac/bind_objc_block.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #import "ios/web/public/navigation_manager.h" |
| 10 #import "ios/web/public/test/web_test_with_web_state.h" | 11 #import "ios/web/public/test/web_test_with_web_state.h" |
| 11 | 12 |
| 12 namespace web { | 13 namespace web { |
| 13 | 14 |
| 14 // Test fixture for web::WebTest class. | 15 // Test fixture for web::WebTest class. |
| 15 typedef web::WebTestWithWebState WebStateTest; | 16 typedef web::WebTestWithWebState WebStateTest; |
| 16 | 17 |
| 17 // Tests script execution with and without callback. | 18 // Tests script execution with and without callback. |
| 18 TEST_F(WebStateTest, ScriptExecution) { | 19 TEST_F(WebStateTest, ScriptExecution) { |
| 19 LoadHtml("<html></html>"); | 20 LoadHtml("<html></html>"); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 " webkit = undefined;" | 68 " webkit = undefined;" |
| 68 " __gCrWeb.message.invokeOnHost({'command': 'test.webkit-overriding'});" | 69 " __gCrWeb.message.invokeOnHost({'command': 'test.webkit-overriding'});" |
| 69 "</script>"); | 70 "</script>"); |
| 70 | 71 |
| 71 WaitForCondition(^{ | 72 WaitForCondition(^{ |
| 72 return message_received; | 73 return message_received; |
| 73 }); | 74 }); |
| 74 web_state()->RemoveScriptCommandCallback("test"); | 75 web_state()->RemoveScriptCommandCallback("test"); |
| 75 } | 76 } |
| 76 | 77 |
| 78 // Tests that reload with web::ReloadType::NORMAL is no-op when navigation |
| 79 // manager is empty. |
| 80 TEST_F(WebStateTest, ReloadWithNormalTypeWithEmptyNavigationManager) { |
| 81 NavigationManager* navigation_manager = web_state()->GetNavigationManager(); |
| 82 ASSERT_FALSE(navigation_manager->GetTransientItem()); |
| 83 ASSERT_FALSE(navigation_manager->GetPendingItem()); |
| 84 ASSERT_FALSE(navigation_manager->GetLastCommittedItem()); |
| 85 |
| 86 navigation_manager->Reload(web::ReloadType::NORMAL, |
| 87 false /* check_for_repost */); |
| 88 |
| 89 ASSERT_FALSE(navigation_manager->GetTransientItem()); |
| 90 ASSERT_FALSE(navigation_manager->GetPendingItem()); |
| 91 ASSERT_FALSE(navigation_manager->GetLastCommittedItem()); |
| 92 } |
| 93 |
| 94 // Tests that reload with web::ReloadType::ORIGINAL_REQUEST_URL is no-op when |
| 95 // navigation manager is empty. |
| 96 TEST_F(WebStateTest, ReloadWithOriginalTypeWithEmptyNavigationManager) { |
| 97 NavigationManager* navigation_manager = web_state()->GetNavigationManager(); |
| 98 ASSERT_FALSE(navigation_manager->GetTransientItem()); |
| 99 ASSERT_FALSE(navigation_manager->GetPendingItem()); |
| 100 ASSERT_FALSE(navigation_manager->GetLastCommittedItem()); |
| 101 |
| 102 navigation_manager->Reload(web::ReloadType::ORIGINAL_REQUEST_URL, |
| 103 false /* check_for_repost */); |
| 104 |
| 105 ASSERT_FALSE(navigation_manager->GetTransientItem()); |
| 106 ASSERT_FALSE(navigation_manager->GetPendingItem()); |
| 107 ASSERT_FALSE(navigation_manager->GetLastCommittedItem()); |
| 108 } |
| 109 |
| 77 } // namespace web | 110 } // namespace web |
| OLD | NEW |