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

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

Issue 2699253002: Removed CRWSessionEntry unittests. (Closed)
Patch Set: add ifndef 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/web/navigation/crw_session_entry.h"
6
7 #import <Foundation/Foundation.h>
8 #include <stdint.h>
9
10 #include <utility>
11
12 #import "base/mac/scoped_nsobject.h"
13 #include "base/strings/sys_string_conversions.h"
14 #import "ios/testing/ocmock_complex_type_helper.h"
15 #import "ios/web/navigation/navigation_item_impl.h"
16 #include "ios/web/public/referrer.h"
17 #import "net/base/mac/url_conversions.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19 #import "testing/gtest_mac.h"
20 #include "testing/platform_test.h"
21 #import "third_party/ocmock/OCMock/OCMock.h"
22 #include "third_party/ocmock/gtest_support.h"
23 #include "ui/base/page_transition_types.h"
24
25 class CRWSessionEntryTest : public PlatformTest {
26 public:
27 static void expectEqualSessionEntries(CRWSessionEntry* entry1,
28 CRWSessionEntry* entry2,
29 ui::PageTransition transition);
30
31 protected:
32 void SetUp() override {
33 GURL url("http://init.test");
34 ui::PageTransition transition =
35 ui::PAGE_TRANSITION_AUTO_BOOKMARK;
36 std::unique_ptr<web::NavigationItemImpl> item(
37 new web::NavigationItemImpl());
38 item->SetOriginalRequestURL(url);
39 item->SetURL(url);
40 item->SetTransitionType(transition);
41 item->SetTimestamp(base::Time::Now());
42 item->SetPostData([@"Test data" dataUsingEncoding:NSUTF8StringEncoding]);
43 item->SetUserAgentType(web::UserAgentType::MOBILE);
44 session_entry_.reset(
45 [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]);
46 }
47
48 protected:
49 base::scoped_nsobject<CRWSessionEntry> session_entry_;
50 };
51
52 void CRWSessionEntryTest::expectEqualSessionEntries(
53 CRWSessionEntry* entry1,
54 CRWSessionEntry* entry2,
55 ui::PageTransition transition) {
56 web::NavigationItemImpl* navItem1 = entry1.navigationItemImpl;
57 web::NavigationItemImpl* navItem2 = entry2.navigationItemImpl;
58 // url is not compared because it could differ after copy or archive.
59 EXPECT_EQ(navItem1->GetVirtualURL(), navItem2->GetVirtualURL());
60 EXPECT_EQ(navItem1->GetReferrer().url, navItem2->GetReferrer().url);
61 EXPECT_EQ(navItem1->GetTimestamp(), navItem2->GetTimestamp());
62 EXPECT_EQ(navItem1->GetTitle(), navItem2->GetTitle());
63 EXPECT_EQ(navItem1->GetPageDisplayState(), navItem2->GetPageDisplayState());
64 EXPECT_EQ(navItem1->ShouldSkipRepostFormConfirmation(),
65 navItem2->ShouldSkipRepostFormConfirmation());
66 EXPECT_EQ(navItem1->GetUserAgentType(), navItem2->GetUserAgentType());
67 EXPECT_TRUE((!navItem1->HasPostData() && !navItem2->HasPostData()) ||
68 [navItem1->GetPostData() isEqualToData:navItem2->GetPostData()]);
69 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
70 navItem2->GetTransitionType(), transition));
71 EXPECT_NSEQ(navItem1->GetHttpRequestHeaders(),
72 navItem2->GetHttpRequestHeaders());
73 }
74
75 TEST_F(CRWSessionEntryTest, Description) {
76 [session_entry_ navigationItem]->SetTitle(base::SysNSStringToUTF16(@"Title"));
77 EXPECT_NSEQ([session_entry_ description],
78 @"url:http://init.test/ originalurl:http://init.test/ "
79 @"title:Title transition:2 displayState:{ scrollOffset:(nan, "
80 @"nan), zoomScaleRange:(nan, nan), zoomScale:nan } "
81 @"userAgentType:MOBILE");
82 }
83
84 TEST_F(CRWSessionEntryTest, EmptyVirtualUrl) {
85 EXPECT_EQ(GURL("http://init.test/"),
86 [session_entry_ navigationItem]->GetURL());
87 }
88
89 TEST_F(CRWSessionEntryTest, NonEmptyVirtualUrl) {
90 web::NavigationItem* item = [session_entry_ navigationItem];
91 item->SetVirtualURL(GURL("http://user.friendly"));
92 EXPECT_EQ(GURL("http://user.friendly/"), item->GetVirtualURL());
93 EXPECT_EQ(GURL("http://init.test/"), item->GetURL());
94 }
95
96 TEST_F(CRWSessionEntryTest, EmptyDescription) {
97 EXPECT_GT([[session_entry_ description] length], 0U);
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