| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/web_state/ui/crw_wk_navigation_states.h" | 5 #import "ios/web/web_state/ui/crw_wk_navigation_states.h" |
| 6 | 6 |
| 7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
| 8 | 8 |
| 9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
| 10 #include "ios/web/web_state/navigation_context_impl.h" | 10 #include "ios/web/web_state/navigation_context_impl.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 [states_ setContext:std::move(context2) forNavigation:navigation1_]; | 103 [states_ setContext:std::move(context2) forNavigation:navigation1_]; |
| 104 EXPECT_FALSE([states_ contextForNavigation:navigation2_]); | 104 EXPECT_FALSE([states_ contextForNavigation:navigation2_]); |
| 105 EXPECT_FALSE([states_ contextForNavigation:navigation3_]); | 105 EXPECT_FALSE([states_ contextForNavigation:navigation3_]); |
| 106 ASSERT_TRUE([states_ contextForNavigation:navigation1_]); | 106 ASSERT_TRUE([states_ contextForNavigation:navigation1_]); |
| 107 EXPECT_EQ(GURL(kTestUrl2), | 107 EXPECT_EQ(GURL(kTestUrl2), |
| 108 [states_ contextForNavigation:navigation1_]->GetUrl()); | 108 [states_ contextForNavigation:navigation1_]->GetUrl()); |
| 109 EXPECT_FALSE([states_ contextForNavigation:navigation1_]->IsSameDocument()); | 109 EXPECT_FALSE([states_ contextForNavigation:navigation1_]->IsSameDocument()); |
| 110 EXPECT_TRUE([states_ contextForNavigation:navigation1_]->IsErrorPage()); | 110 EXPECT_TRUE([states_ contextForNavigation:navigation1_]->IsErrorPage()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Tests null WKNavigation object. |
| 114 TEST_F(CRWWKNavigationStatesTest, NullNavigation) { |
| 115 // navigation_1 is the only navigation and it is the latest. |
| 116 [states_ setState:WKNavigationState::REQUESTED forNavigation:navigation1_]; |
| 117 ASSERT_EQ(navigation1_, [states_ lastAddedNavigation]); |
| 118 EXPECT_EQ(WKNavigationState::REQUESTED, [states_ lastAddedNavigationState]); |
| 119 |
| 120 // null navigation is added later and hence the latest. |
| 121 [states_ setState:WKNavigationState::STARTED forNavigation:nil]; |
| 122 EXPECT_FALSE([states_ lastAddedNavigation]); |
| 123 EXPECT_EQ(WKNavigationState::STARTED, [states_ lastAddedNavigationState]); |
| 124 |
| 125 // navigation_1 is the is the latest again after removing null navigation. |
| 126 [states_ removeNavigation:nil]; |
| 127 ASSERT_EQ(navigation1_, [states_ lastAddedNavigation]); |
| 128 EXPECT_EQ(WKNavigationState::REQUESTED, [states_ lastAddedNavigationState]); |
| 129 } |
| 130 |
| 113 } // namespace web | 131 } // namespace web |
| OLD | NEW |