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

Side by Side Diff: ios/web/navigation/navigation_manager_util_unittest.mm

Issue 2875153003: Added web::GetCommittedItemWithUniqueID function. (Closed)
Patch Set: Added GetCommittedItemIndexWithUniqueID Created 3 years, 6 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/navigation/navigation_manager_util.mm ('k') | ios/web/net/crw_ssl_status_updater.mm » ('j') | 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 2017 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 #include "ios/web/navigation/navigation_manager_util.h"
6
7 #include "base/memory/ptr_util.h"
8 #import "ios/web/navigation/crw_session_controller+private_constructors.h"
9 #import "ios/web/navigation/crw_session_controller.h"
10 #import "ios/web/navigation/navigation_manager_impl.h"
11 #import "ios/web/public/navigation_item.h"
12 #include "ios/web/public/test/fakes/test_browser_state.h"
13 #include "testing/platform_test.h"
14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
19 namespace web {
20
21 // Test fixture testing navigation_manager_util.h functions.
22 class NavigationManagerUtilTest : public PlatformTest {
23 protected:
24 NavigationManagerUtilTest()
25 : controller_([[CRWSessionController alloc]
26 initWithBrowserState:&browser_state_]) {
27 manager_.SetSessionController(controller_);
28 }
29
30 NavigationManagerImpl manager_;
31 CRWSessionController* controller_;
32
33 private:
34 TestBrowserState browser_state_;
35 };
36
37 // Tests GetCommittedItemWithUniqueID and GetCommittedItemIndexWithUniqueID
38 // functions.
39 TEST_F(NavigationManagerUtilTest, GetCommittedItemWithUniqueID) {
40 // Start with NavigationManager that only has a pending item.
41 manager_.AddPendingItem(
42 GURL("http://chromium.org"), Referrer(), ui::PAGE_TRANSITION_TYPED,
43 web::NavigationInitiationType::USER_INITIATED,
44 web::NavigationManager::UserAgentOverrideOption::INHERIT);
45 NavigationItem* item = manager_.GetPendingItem();
46 int unique_id = item->GetUniqueID();
47 EXPECT_FALSE(GetCommittedItemWithUniqueID(&manager_, unique_id));
48 EXPECT_EQ(-1, GetCommittedItemIndexWithUniqueID(&manager_, unique_id));
49
50 // Commit that pending item.
51 [controller_ commitPendingItem];
52 EXPECT_EQ(item, GetCommittedItemWithUniqueID(&manager_, unique_id));
53 EXPECT_EQ(0, GetCommittedItemIndexWithUniqueID(&manager_, unique_id));
54
55 // Remove committed item.
56 manager_.RemoveItemAtIndex(0);
57 EXPECT_FALSE(GetCommittedItemWithUniqueID(&manager_, unique_id));
58 EXPECT_EQ(-1, GetCommittedItemIndexWithUniqueID(&manager_, unique_id));
59 }
60
61 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/navigation/navigation_manager_util.mm ('k') | ios/web/net/crw_ssl_status_updater.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698