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

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

Issue 2699253002: Removed CRWSessionEntry unittests. (Closed)
Patch Set: Created 3 years, 10 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
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 session_entry_.reset(
44 [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]);
45 }
46
47 protected:
48 base::scoped_nsobject<CRWSessionEntry> session_entry_;
49 };
50
51 void CRWSessionEntryTest::expectEqualSessionEntries(
52 CRWSessionEntry* entry1,
53 CRWSessionEntry* entry2,
54 ui::PageTransition transition) {
55 web::NavigationItemImpl* navItem1 = entry1.navigationItemImpl;
56 web::NavigationItemImpl* navItem2 = entry2.navigationItemImpl;
57 // url is not compared because it could differ after copy or archive.
58 EXPECT_EQ(navItem1->GetVirtualURL(), navItem2->GetVirtualURL());
59 EXPECT_EQ(navItem1->GetReferrer().url, navItem2->GetReferrer().url);
60 EXPECT_EQ(navItem1->GetTimestamp(), navItem2->GetTimestamp());
61 EXPECT_EQ(navItem1->GetTitle(), navItem2->GetTitle());
62 EXPECT_EQ(navItem1->GetPageDisplayState(), navItem2->GetPageDisplayState());
63 EXPECT_EQ(navItem1->ShouldSkipRepostFormConfirmation(),
64 navItem2->ShouldSkipRepostFormConfirmation());
65 EXPECT_EQ(navItem1->IsOverridingUserAgent(),
66 navItem2->IsOverridingUserAgent());
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 } desktopUA:0");
81 }
82
83 TEST_F(CRWSessionEntryTest, EmptyVirtualUrl) {
Eugene But (OOO till 7-30) 2017/02/18 01:25:59 Could you please move VirtualURL tests to navigati
kkhorimoto 2017/03/02 01:55:55 This test doesn't even set anything related to the
84 EXPECT_EQ(GURL("http://init.test/"),
85 [session_entry_ navigationItem]->GetURL());
86 }
87
88 TEST_F(CRWSessionEntryTest, NonEmptyVirtualUrl) {
kkhorimoto 2017/03/02 01:55:55 An improved version of this test has been added to
89 web::NavigationItem* item = [session_entry_ navigationItem];
90 item->SetVirtualURL(GURL("http://user.friendly"));
91 EXPECT_EQ(GURL("http://user.friendly/"), item->GetVirtualURL());
92 EXPECT_EQ(GURL("http://init.test/"), item->GetURL());
93 }
94
95 TEST_F(CRWSessionEntryTest, EmptyDescription) {
kkhorimoto 2017/03/02 01:55:55 This functionality is already tested by the descri
96 EXPECT_GT([[session_entry_ description] length], 0U);
97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698