OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/navigation/navigation_manager_impl.h" | 5 #import "ios/web/navigation/navigation_manager_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/bind_objc_block.h" | 8 #include "base/mac/bind_objc_block.h" |
9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
10 #import "ios/web/navigation/crw_session_controller+private_constructors.h" | 10 #import "ios/web/navigation/crw_session_controller+private_constructors.h" |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 GURL url4(url::SchemeHostPort(kSchemeToRewrite, "test4", 0).Serialize()); | 1356 GURL url4(url::SchemeHostPort(kSchemeToRewrite, "test4", 0).Serialize()); |
1357 navigation_manager()->AddPendingItem( | 1357 navigation_manager()->AddPendingItem( |
1358 url4, Referrer(), ui::PAGE_TRANSITION_LINK, | 1358 url4, Referrer(), ui::PAGE_TRANSITION_LINK, |
1359 web::NavigationInitiationType::RENDERER_INITIATED, | 1359 web::NavigationInitiationType::RENDERER_INITIATED, |
1360 web::NavigationManager::UserAgentOverrideOption::INHERIT); | 1360 web::NavigationManager::UserAgentOverrideOption::INHERIT); |
1361 GURL rewritten_url4( | 1361 GURL rewritten_url4( |
1362 url::SchemeHostPort(kTestWebUIScheme, "test4", 0).Serialize()); | 1362 url::SchemeHostPort(kTestWebUIScheme, "test4", 0).Serialize()); |
1363 EXPECT_EQ(rewritten_url4, navigation_manager()->GetPendingItem()->GetURL()); | 1363 EXPECT_EQ(rewritten_url4, navigation_manager()->GetPendingItem()->GetURL()); |
1364 } | 1364 } |
1365 | 1365 |
| 1366 // Tests that GetIndexOfItem() returns the correct values. |
| 1367 TEST_F(NavigationManagerTest, GetIndexOfItem) { |
| 1368 // Create two items and add them to the NavigationManagerImpl. |
| 1369 navigation_manager()->AddPendingItem( |
| 1370 GURL("http://www.url.com/0"), Referrer(), ui::PAGE_TRANSITION_TYPED, |
| 1371 web::NavigationInitiationType::USER_INITIATED, |
| 1372 web::NavigationManager::UserAgentOverrideOption::INHERIT); |
| 1373 navigation_manager()->CommitPendingItem(); |
| 1374 web::NavigationItem* item0 = navigation_manager()->GetLastCommittedItem(); |
| 1375 navigation_manager()->AddPendingItem( |
| 1376 GURL("http://www.url.com/1"), Referrer(), ui::PAGE_TRANSITION_TYPED, |
| 1377 web::NavigationInitiationType::USER_INITIATED, |
| 1378 web::NavigationManager::UserAgentOverrideOption::INHERIT); |
| 1379 navigation_manager()->CommitPendingItem(); |
| 1380 web::NavigationItem* item1 = navigation_manager()->GetLastCommittedItem(); |
| 1381 // Create an item that does not exist in the NavigationManagerImpl. |
| 1382 std::unique_ptr<web::NavigationItem> item_not_found = |
| 1383 web::NavigationItem::Create(); |
| 1384 // Verify GetIndexOfItem() results. |
| 1385 EXPECT_EQ(0, navigation_manager()->GetIndexOfItem(item0)); |
| 1386 EXPECT_EQ(1, navigation_manager()->GetIndexOfItem(item1)); |
| 1387 EXPECT_EQ(-1, navigation_manager()->GetIndexOfItem(item_not_found.get())); |
| 1388 } |
| 1389 |
1366 } // namespace web | 1390 } // namespace web |
OLD | NEW |