Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: ios/web/web_state/ui/crw_wk_navigation_states_unittest.mm

Issue 2601083003: [ios] Correctly determine last seen WKNavigation object. (Closed)
Patch Set: Addressed more comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/web/web_state/ui/crw_wk_navigation_states.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/web/web_state/ui/crw_wk_navigation_states.h"
6
7 #import <WebKit/WebKit.h>
8
9 #import "base/mac/scoped_nsobject.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h"
12
13 namespace web {
14
15 // Test fixture for CRWWKNavigationStates testing.
16 class CRWWKNavigationStatesTest : public PlatformTest {
17 protected:
18 CRWWKNavigationStatesTest()
19 : navigation1_(static_cast<WKNavigation*>([[NSObject alloc] init])),
20 navigation2_(static_cast<WKNavigation*>([[NSObject alloc] init])),
21 states_([[CRWWKNavigationStates alloc] init]) {}
22
23 protected:
24 base::scoped_nsobject<WKNavigation> navigation1_;
25 base::scoped_nsobject<WKNavigation> navigation2_;
26 base::scoped_nsobject<CRWWKNavigationStates> states_;
27 };
28
29 // Tests |lastAddedNavigation| method.
30 TEST_F(CRWWKNavigationStatesTest, LastAddedNavigation) {
31 // navigation_1 is the only navigation and it is the latest.
32 [states_ setState:WKNavigationState::REQUESTED forNavigation:navigation1_];
33 EXPECT_EQ(navigation1_, [states_ lastAddedNavigation]);
34
35 // navigation_2 is added later and hence the latest.
36 [states_ setState:WKNavigationState::REQUESTED forNavigation:navigation2_];
37 EXPECT_EQ(navigation2_, [states_ lastAddedNavigation]);
38
39 // Updating state for existing navigation does not make it the latest.
40 [states_ setState:WKNavigationState::STARTED forNavigation:navigation1_];
41 EXPECT_EQ(navigation2_, [states_ lastAddedNavigation]);
42 }
43
44 // Tests |stateForNavigation:| method.
45 TEST_F(CRWWKNavigationStatesTest, StateForNavigation) {
46 [states_ setState:WKNavigationState::REQUESTED forNavigation:navigation1_];
47 EXPECT_EQ(WKNavigationState::REQUESTED,
48 [states_ stateForNavigation:navigation1_]);
49
50 [states_ setState:WKNavigationState::REQUESTED forNavigation:navigation2_];
51 EXPECT_EQ(WKNavigationState::REQUESTED,
52 [states_ stateForNavigation:navigation2_]);
53
54 [states_ setState:WKNavigationState::STARTED forNavigation:navigation1_];
55 EXPECT_EQ(WKNavigationState::STARTED,
56 [states_ stateForNavigation:navigation1_]);
57 }
58
59 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/crw_wk_navigation_states.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698