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 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
9 #import "ios/web/navigation/crw_session_controller+private_constructors.h" | 9 #import "ios/web/navigation/crw_session_controller+private_constructors.h" |
10 #import "ios/web/navigation/navigation_manager_delegate.h" | 10 #import "ios/web/navigation/navigation_manager_delegate.h" |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 } | 508 } |
509 | 509 |
510 // Tests that desktop user agent can be enforced to use for next pending item. | 510 // Tests that desktop user agent can be enforced to use for next pending item. |
511 TEST_F(NavigationManagerTest, OverrideDesktopUserAgent) { | 511 TEST_F(NavigationManagerTest, OverrideDesktopUserAgent) { |
512 navigation_manager()->OverrideDesktopUserAgentForNextPendingItem(); | 512 navigation_manager()->OverrideDesktopUserAgentForNextPendingItem(); |
513 navigation_manager()->AddPendingItem( | 513 navigation_manager()->AddPendingItem( |
514 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | 514 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, |
515 web::NavigationInitiationType::USER_INITIATED); | 515 web::NavigationInitiationType::USER_INITIATED); |
516 [session_controller() commitPendingItem]; | 516 [session_controller() commitPendingItem]; |
517 NavigationItem* visible_item = navigation_manager()->GetVisibleItem(); | 517 NavigationItem* visible_item = navigation_manager()->GetVisibleItem(); |
518 EXPECT_TRUE(visible_item->IsOverridingUserAgent()); | 518 EXPECT_EQ(visible_item->GetUserAgentType(), UserAgentType::DESKTOP); |
519 } | |
520 | |
521 // Tests that the UserAgentType is propagated to subsequent NavigationItems. | |
522 TEST_F(NavigationManagerTest, UserAgentTypePropagation) { | |
523 // Test that the first item's UA type is propagated to the second. | |
Eugene But (OOO till 7-30)
2017/03/02 03:36:34
Do you want to use linebreaks for the code to sepa
kkhorimoto
2017/03/02 04:12:55
Done.
| |
524 navigation_manager()->AddPendingItem( | |
525 GURL("http://www.1.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | |
526 web::NavigationInitiationType::USER_INITIATED); | |
527 [session_controller() commitPendingItem]; | |
528 web::NavigationItem* item1 = navigation_manager()->GetLastCommittedItem(); | |
529 ASSERT_EQ(web::UserAgentType::MOBILE, item1->GetUserAgentType()); | |
530 navigation_manager()->AddPendingItem( | |
531 GURL("http://www.2.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | |
532 web::NavigationInitiationType::USER_INITIATED); | |
533 [session_controller() commitPendingItem]; | |
534 web::NavigationItem* item2 = navigation_manager()->GetLastCommittedItem(); | |
535 EXPECT_EQ(item1->GetUserAgentType(), item2->GetUserAgentType()); | |
536 // Update |item2|'s UA type to DESKTOP and verify that it is propagated to | |
537 // |item3|. | |
538 item2->SetUserAgentType(web::UserAgentType::DESKTOP); | |
539 ASSERT_EQ(web::UserAgentType::DESKTOP, item2->GetUserAgentType()); | |
540 navigation_manager()->AddPendingItem( | |
541 GURL("http://www.3.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | |
542 web::NavigationInitiationType::USER_INITIATED); | |
543 [session_controller() commitPendingItem]; | |
544 web::NavigationItem* item3 = navigation_manager()->GetLastCommittedItem(); | |
545 EXPECT_EQ(item2->GetUserAgentType(), item3->GetUserAgentType()); | |
546 } | |
547 | |
548 // Tests that the UserAgentType is propagated to subsequent NavigationItems if | |
549 // a native URL exists in between naviations. | |
550 TEST_F(NavigationManagerTest, UserAgentTypePropagationPastNativeItems) { | |
551 // Test that the first item's UA type is propagated to the second when a | |
552 // native page separates the navigations. | |
553 navigation_manager()->AddPendingItem( | |
554 GURL("http://www.1.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | |
555 web::NavigationInitiationType::USER_INITIATED); | |
556 [session_controller() commitPendingItem]; | |
557 web::NavigationItem* item1 = navigation_manager()->GetLastCommittedItem(); | |
558 ASSERT_EQ(web::UserAgentType::MOBILE, item1->GetUserAgentType()); | |
559 navigation_manager()->AddPendingItem( | |
560 GURL("testnativecontent://native1"), Referrer(), | |
Eugene But (OOO till 7-30)
2017/03/02 03:36:34
Please use kTestNativeContentScheme instead of har
kkhorimoto
2017/03/02 04:12:55
Done.
| |
561 ui::PAGE_TRANSITION_TYPED, web::NavigationInitiationType::USER_INITIATED); | |
562 [session_controller() commitPendingItem]; | |
563 web::NavigationItem* nativeItem1 = | |
Eugene But (OOO till 7-30)
2017/03/02 03:36:34
native_item1
kkhorimoto
2017/03/02 04:12:55
Done.
| |
564 navigation_manager()->GetLastCommittedItem(); | |
565 ASSERT_EQ(web::UserAgentType::NONE, nativeItem1->GetUserAgentType()); | |
566 navigation_manager()->AddPendingItem( | |
567 GURL("http://www.2.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | |
568 web::NavigationInitiationType::USER_INITIATED); | |
569 [session_controller() commitPendingItem]; | |
570 web::NavigationItem* item2 = navigation_manager()->GetLastCommittedItem(); | |
571 EXPECT_EQ(item1->GetUserAgentType(), item2->GetUserAgentType()); | |
572 // Update |item2|'s UA type to DESKTOP and verify that it is propagated to | |
573 // |item3| when a native page separates the navigations. | |
574 item2->SetUserAgentType(web::UserAgentType::DESKTOP); | |
575 ASSERT_EQ(web::UserAgentType::DESKTOP, item2->GetUserAgentType()); | |
576 navigation_manager()->AddPendingItem( | |
577 GURL("testnativecontent://native2"), Referrer(), | |
578 ui::PAGE_TRANSITION_TYPED, web::NavigationInitiationType::USER_INITIATED); | |
579 [session_controller() commitPendingItem]; | |
580 web::NavigationItem* nativeItem2 = | |
581 navigation_manager()->GetLastCommittedItem(); | |
582 ASSERT_EQ(web::UserAgentType::NONE, nativeItem2->GetUserAgentType()); | |
583 navigation_manager()->AddPendingItem( | |
584 GURL("http://www.3.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | |
585 web::NavigationInitiationType::USER_INITIATED); | |
586 [session_controller() commitPendingItem]; | |
587 web::NavigationItem* item3 = navigation_manager()->GetLastCommittedItem(); | |
588 EXPECT_EQ(item2->GetUserAgentType(), item3->GetUserAgentType()); | |
519 } | 589 } |
520 | 590 |
521 } // namespace web | 591 } // namespace web |
OLD | NEW |