OLD | NEW |
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" |
| 6 |
5 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
6 #include <stdint.h> | 8 #include <stdint.h> |
7 | 9 |
| 10 #include <utility> |
| 11 |
8 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
9 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
10 #import "ios/testing/ocmock_complex_type_helper.h" | 14 #import "ios/testing/ocmock_complex_type_helper.h" |
11 #import "ios/web/navigation/crw_session_entry.h" | |
12 #include "ios/web/navigation/navigation_item_impl.h" | 15 #include "ios/web/navigation/navigation_item_impl.h" |
13 #include "ios/web/public/referrer.h" | 16 #include "ios/web/public/referrer.h" |
14 #import "net/base/mac/url_conversions.h" | 17 #import "net/base/mac/url_conversions.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/gtest_mac.h" | 19 #include "testing/gtest_mac.h" |
17 #include "testing/platform_test.h" | 20 #include "testing/platform_test.h" |
18 #import "third_party/ocmock/OCMock/OCMock.h" | 21 #import "third_party/ocmock/OCMock/OCMock.h" |
19 #include "third_party/ocmock/gtest_support.h" | 22 #include "third_party/ocmock/gtest_support.h" |
20 #include "ui/base/page_transition_types.h" | 23 #include "ui/base/page_transition_types.h" |
21 | 24 |
(...skipping 13 matching lines...) Expand all Loading... |
35 void SetUp() override { | 38 void SetUp() override { |
36 GURL url("http://init.test"); | 39 GURL url("http://init.test"); |
37 ui::PageTransition transition = | 40 ui::PageTransition transition = |
38 ui::PAGE_TRANSITION_AUTO_BOOKMARK; | 41 ui::PAGE_TRANSITION_AUTO_BOOKMARK; |
39 scoped_ptr<web::NavigationItemImpl> item(new web::NavigationItemImpl()); | 42 scoped_ptr<web::NavigationItemImpl> item(new web::NavigationItemImpl()); |
40 item->SetURL(url); | 43 item->SetURL(url); |
41 item->SetTransitionType(transition); | 44 item->SetTransitionType(transition); |
42 item->SetTimestamp(base::Time::Now()); | 45 item->SetTimestamp(base::Time::Now()); |
43 item->SetPostData([@"Test data" dataUsingEncoding:NSUTF8StringEncoding]); | 46 item->SetPostData([@"Test data" dataUsingEncoding:NSUTF8StringEncoding]); |
44 sessionEntry_.reset( | 47 sessionEntry_.reset( |
45 [[CRWSessionEntry alloc] initWithNavigationItem:item.Pass()]); | 48 [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]); |
46 } | 49 } |
47 void TearDown() override { sessionEntry_.reset(); } | 50 void TearDown() override { sessionEntry_.reset(); } |
48 | 51 |
49 protected: | 52 protected: |
50 base::scoped_nsobject<CRWSessionEntry> sessionEntry_; | 53 base::scoped_nsobject<CRWSessionEntry> sessionEntry_; |
51 }; | 54 }; |
52 | 55 |
53 @implementation OCMockComplexTypeHelper (CRWSessionEntryTest) | 56 @implementation OCMockComplexTypeHelper (CRWSessionEntryTest) |
54 typedef void (^encodeBytes_length_forKey_block)( | 57 typedef void (^encodeBytes_length_forKey_block)( |
55 const uint8_t*, NSUInteger, NSString*); | 58 const uint8_t*, NSUInteger, NSString*); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 TEST_F(CRWSessionEntryTest, NonEmptyVirtualUrl) { | 327 TEST_F(CRWSessionEntryTest, NonEmptyVirtualUrl) { |
325 web::NavigationItem* item = [sessionEntry_ navigationItem]; | 328 web::NavigationItem* item = [sessionEntry_ navigationItem]; |
326 item->SetVirtualURL(GURL("http://user.friendly")); | 329 item->SetVirtualURL(GURL("http://user.friendly")); |
327 EXPECT_EQ(GURL("http://user.friendly/"), item->GetVirtualURL()); | 330 EXPECT_EQ(GURL("http://user.friendly/"), item->GetVirtualURL()); |
328 EXPECT_EQ(GURL("http://init.test/"), item->GetURL()); | 331 EXPECT_EQ(GURL("http://init.test/"), item->GetURL()); |
329 } | 332 } |
330 | 333 |
331 TEST_F(CRWSessionEntryTest, EmptyDescription) { | 334 TEST_F(CRWSessionEntryTest, EmptyDescription) { |
332 EXPECT_GT([[sessionEntry_ description] length], 0U); | 335 EXPECT_GT([[sessionEntry_ description] length], 0U); |
333 } | 336 } |
OLD | NEW |