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

Unified Diff: ios/web/navigation/navigation_manager_impl_unittest.mm

Issue 2779263002: Set user agent type of transient item the same as pending item. (Closed)
Patch Set: Remove code duplication Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/navigation/navigation_manager_impl_unittest.mm
diff --git a/ios/web/navigation/navigation_manager_impl_unittest.mm b/ios/web/navigation/navigation_manager_impl_unittest.mm
index 2b3f2229ef1b73dcc3418e88e27344018b5c2b6c..b6b09de3eca8dbf0d79c43e7c3ebac0387f4bc8c 100644
--- a/ios/web/navigation/navigation_manager_impl_unittest.mm
+++ b/ios/web/navigation/navigation_manager_impl_unittest.mm
@@ -587,6 +587,42 @@ TestNavigationManagerDelegate navigation_manager_delegate() {
EXPECT_EQ(item2->GetUserAgentType(), item3->GetUserAgentType());
}
+// Tests that adding transient item for a pending item with mobile user agent
+// type results in a transient item with mobile user agent type.
+TEST_F(NavigationManagerTest, AddTransientItemForMobilePendingItem) {
+ navigation_manager()->AddPendingItem(
+ GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED,
+ web::NavigationInitiationType::USER_INITIATED);
+ ASSERT_TRUE(navigation_manager()->GetPendingItem());
+ navigation_manager()->GetPendingItem()->SetUserAgentType(
+ UserAgentType::MOBILE);
+
+ navigation_manager()->AddTransientItem(GURL("http://www.url.com"));
+ ASSERT_TRUE(navigation_manager()->GetTransientItem());
+ EXPECT_EQ(UserAgentType::MOBILE,
+ navigation_manager()->GetTransientItem()->GetUserAgentType());
+ EXPECT_EQ(UserAgentType::MOBILE,
+ navigation_manager()->GetPendingItem()->GetUserAgentType());
+}
+
+// Tests that adding transient item for a pending item with desktop user agent
+// type results in a transient item with desktop user agent type.
+TEST_F(NavigationManagerTest, AddTransientItemForDesktopPendingItem) {
+ navigation_manager()->AddPendingItem(
+ GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED,
+ web::NavigationInitiationType::USER_INITIATED);
+ ASSERT_TRUE(navigation_manager()->GetPendingItem());
+ navigation_manager()->GetPendingItem()->SetUserAgentType(
+ UserAgentType::DESKTOP);
+
+ navigation_manager()->AddTransientItem(GURL("http://www.url.com"));
+ ASSERT_TRUE(navigation_manager()->GetTransientItem());
+ EXPECT_EQ(UserAgentType::DESKTOP,
+ navigation_manager()->GetTransientItem()->GetUserAgentType());
+ EXPECT_EQ(UserAgentType::DESKTOP,
+ navigation_manager()->GetPendingItem()->GetUserAgentType());
+}
+
// Tests that calling |Reload| with web::ReloadType::NORMAL is no-op when there
// are no transient, pending and committed items.
TEST_F(NavigationManagerTest, ReloadEmptyWithNormalType) {

Powered by Google App Engine
This is Rietveld 408576698