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

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

Issue 2705293014: Created web::UserAgentType. (Closed)
Patch Set: rebase + compile fix 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 unified diff | Download patch
« no previous file with comments | « ios/web/navigation/crw_session_entry.mm ('k') | ios/web/navigation/navigation_item_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/crw_session_entry.h" 5 #import "ios/web/navigation/crw_session_entry.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 22 matching lines...) Expand all
33 GURL url("http://init.test"); 33 GURL url("http://init.test");
34 ui::PageTransition transition = 34 ui::PageTransition transition =
35 ui::PAGE_TRANSITION_AUTO_BOOKMARK; 35 ui::PAGE_TRANSITION_AUTO_BOOKMARK;
36 std::unique_ptr<web::NavigationItemImpl> item( 36 std::unique_ptr<web::NavigationItemImpl> item(
37 new web::NavigationItemImpl()); 37 new web::NavigationItemImpl());
38 item->SetOriginalRequestURL(url); 38 item->SetOriginalRequestURL(url);
39 item->SetURL(url); 39 item->SetURL(url);
40 item->SetTransitionType(transition); 40 item->SetTransitionType(transition);
41 item->SetTimestamp(base::Time::Now()); 41 item->SetTimestamp(base::Time::Now());
42 item->SetPostData([@"Test data" dataUsingEncoding:NSUTF8StringEncoding]); 42 item->SetPostData([@"Test data" dataUsingEncoding:NSUTF8StringEncoding]);
43 item->SetUserAgentType(web::UserAgentType::MOBILE);
43 session_entry_.reset( 44 session_entry_.reset(
44 [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]); 45 [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]);
45 } 46 }
46 47
47 protected: 48 protected:
48 base::scoped_nsobject<CRWSessionEntry> session_entry_; 49 base::scoped_nsobject<CRWSessionEntry> session_entry_;
49 }; 50 };
50 51
51 void CRWSessionEntryTest::expectEqualSessionEntries( 52 void CRWSessionEntryTest::expectEqualSessionEntries(
52 CRWSessionEntry* entry1, 53 CRWSessionEntry* entry1,
53 CRWSessionEntry* entry2, 54 CRWSessionEntry* entry2,
54 ui::PageTransition transition) { 55 ui::PageTransition transition) {
55 web::NavigationItemImpl* navItem1 = entry1.navigationItemImpl; 56 web::NavigationItemImpl* navItem1 = entry1.navigationItemImpl;
56 web::NavigationItemImpl* navItem2 = entry2.navigationItemImpl; 57 web::NavigationItemImpl* navItem2 = entry2.navigationItemImpl;
57 // url is not compared because it could differ after copy or archive. 58 // url is not compared because it could differ after copy or archive.
58 EXPECT_EQ(navItem1->GetVirtualURL(), navItem2->GetVirtualURL()); 59 EXPECT_EQ(navItem1->GetVirtualURL(), navItem2->GetVirtualURL());
59 EXPECT_EQ(navItem1->GetReferrer().url, navItem2->GetReferrer().url); 60 EXPECT_EQ(navItem1->GetReferrer().url, navItem2->GetReferrer().url);
60 EXPECT_EQ(navItem1->GetTimestamp(), navItem2->GetTimestamp()); 61 EXPECT_EQ(navItem1->GetTimestamp(), navItem2->GetTimestamp());
61 EXPECT_EQ(navItem1->GetTitle(), navItem2->GetTitle()); 62 EXPECT_EQ(navItem1->GetTitle(), navItem2->GetTitle());
62 EXPECT_EQ(navItem1->GetPageDisplayState(), navItem2->GetPageDisplayState()); 63 EXPECT_EQ(navItem1->GetPageDisplayState(), navItem2->GetPageDisplayState());
63 EXPECT_EQ(navItem1->ShouldSkipRepostFormConfirmation(), 64 EXPECT_EQ(navItem1->ShouldSkipRepostFormConfirmation(),
64 navItem2->ShouldSkipRepostFormConfirmation()); 65 navItem2->ShouldSkipRepostFormConfirmation());
65 EXPECT_EQ(navItem1->IsOverridingUserAgent(), 66 EXPECT_EQ(navItem1->GetUserAgentType(), navItem2->GetUserAgentType());
66 navItem2->IsOverridingUserAgent());
67 EXPECT_TRUE((!navItem1->HasPostData() && !navItem2->HasPostData()) || 67 EXPECT_TRUE((!navItem1->HasPostData() && !navItem2->HasPostData()) ||
68 [navItem1->GetPostData() isEqualToData:navItem2->GetPostData()]); 68 [navItem1->GetPostData() isEqualToData:navItem2->GetPostData()]);
69 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( 69 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
70 navItem2->GetTransitionType(), transition)); 70 navItem2->GetTransitionType(), transition));
71 EXPECT_NSEQ(navItem1->GetHttpRequestHeaders(), 71 EXPECT_NSEQ(navItem1->GetHttpRequestHeaders(),
72 navItem2->GetHttpRequestHeaders()); 72 navItem2->GetHttpRequestHeaders());
73 } 73 }
74 74
75 TEST_F(CRWSessionEntryTest, Description) { 75 TEST_F(CRWSessionEntryTest, Description) {
76 [session_entry_ navigationItem]->SetTitle(base::SysNSStringToUTF16(@"Title")); 76 [session_entry_ navigationItem]->SetTitle(base::SysNSStringToUTF16(@"Title"));
77 EXPECT_NSEQ([session_entry_ description], 77 EXPECT_NSEQ([session_entry_ description],
78 @"url:http://init.test/ originalurl:http://init.test/ " 78 @"url:http://init.test/ originalurl:http://init.test/ "
79 @"title:Title transition:2 displayState:{ scrollOffset:(nan, " 79 @"title:Title transition:2 displayState:{ scrollOffset:(nan, "
80 @"nan), zoomScaleRange:(nan, nan), zoomScale:nan } desktopUA:0"); 80 @"nan), zoomScaleRange:(nan, nan), zoomScale:nan } "
81 @"userAgentType:MOBILE");
81 } 82 }
82 83
83 TEST_F(CRWSessionEntryTest, EmptyVirtualUrl) { 84 TEST_F(CRWSessionEntryTest, EmptyVirtualUrl) {
84 EXPECT_EQ(GURL("http://init.test/"), 85 EXPECT_EQ(GURL("http://init.test/"),
85 [session_entry_ navigationItem]->GetURL()); 86 [session_entry_ navigationItem]->GetURL());
86 } 87 }
87 88
88 TEST_F(CRWSessionEntryTest, NonEmptyVirtualUrl) { 89 TEST_F(CRWSessionEntryTest, NonEmptyVirtualUrl) {
89 web::NavigationItem* item = [session_entry_ navigationItem]; 90 web::NavigationItem* item = [session_entry_ navigationItem];
90 item->SetVirtualURL(GURL("http://user.friendly")); 91 item->SetVirtualURL(GURL("http://user.friendly"));
91 EXPECT_EQ(GURL("http://user.friendly/"), item->GetVirtualURL()); 92 EXPECT_EQ(GURL("http://user.friendly/"), item->GetVirtualURL());
92 EXPECT_EQ(GURL("http://init.test/"), item->GetURL()); 93 EXPECT_EQ(GURL("http://init.test/"), item->GetURL());
93 } 94 }
94 95
95 TEST_F(CRWSessionEntryTest, EmptyDescription) { 96 TEST_F(CRWSessionEntryTest, EmptyDescription) {
96 EXPECT_GT([[session_entry_ description] length], 0U); 97 EXPECT_GT([[session_entry_ description] length], 0U);
97 } 98 }
OLDNEW
« no previous file with comments | « ios/web/navigation/crw_session_entry.mm ('k') | ios/web/navigation/navigation_item_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698