| 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 "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 base::scoped_nsobject<WKNavigation> navigation1_; | 24 base::scoped_nsobject<WKNavigation> navigation1_; |
| 25 base::scoped_nsobject<WKNavigation> navigation2_; | 25 base::scoped_nsobject<WKNavigation> navigation2_; |
| 26 base::scoped_nsobject<CRWWKNavigationStates> states_; | 26 base::scoped_nsobject<CRWWKNavigationStates> states_; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 // Tests |lastAddedNavigation| method. | 29 // Tests |lastAddedNavigation| method. |
| 30 TEST_F(CRWWKNavigationStatesTest, LastAddedNavigation) { | 30 TEST_F(CRWWKNavigationStatesTest, LastAddedNavigation) { |
| 31 // navigation_1 is the only navigation and it is the latest. | 31 // navigation_1 is the only navigation and it is the latest. |
| 32 [states_ setState:WKNavigationState::REQUESTED forNavigation:navigation1_]; | 32 [states_ setState:WKNavigationState::REQUESTED forNavigation:navigation1_]; |
| 33 EXPECT_EQ(navigation1_, [states_ lastAddedNavigation]); | 33 EXPECT_EQ(navigation1_, [states_ lastAddedNavigation]); |
| 34 EXPECT_EQ(WKNavigationState::REQUESTED, [states_ lastAddedNavigationState]); |
| 34 | 35 |
| 35 // navigation_2 is added later and hence the latest. | 36 // navigation_2 is added later and hence the latest. |
| 36 [states_ setState:WKNavigationState::REQUESTED forNavigation:navigation2_]; | 37 [states_ setState:WKNavigationState::REQUESTED forNavigation:navigation2_]; |
| 37 EXPECT_EQ(navigation2_, [states_ lastAddedNavigation]); | 38 EXPECT_EQ(navigation2_, [states_ lastAddedNavigation]); |
| 39 EXPECT_EQ(WKNavigationState::REQUESTED, [states_ lastAddedNavigationState]); |
| 38 | 40 |
| 39 // Updating state for existing navigation does not make it the latest. | 41 // Updating state for existing navigation does not make it the latest. |
| 40 [states_ setState:WKNavigationState::STARTED forNavigation:navigation1_]; | 42 [states_ setState:WKNavigationState::STARTED forNavigation:navigation1_]; |
| 41 EXPECT_EQ(navigation2_, [states_ lastAddedNavigation]); | 43 EXPECT_EQ(navigation2_, [states_ lastAddedNavigation]); |
| 44 EXPECT_EQ(WKNavigationState::REQUESTED, [states_ lastAddedNavigationState]); |
| 45 |
| 46 // navigation_2 is still the latest. |
| 47 [states_ setState:WKNavigationState::STARTED forNavigation:navigation2_]; |
| 48 EXPECT_EQ(navigation2_, [states_ lastAddedNavigation]); |
| 49 EXPECT_EQ(WKNavigationState::STARTED, [states_ lastAddedNavigationState]); |
| 42 } | 50 } |
| 43 | 51 |
| 44 } // namespace web | 52 } // namespace web |
| OLD | NEW |