OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/navigation_item_impl.h" | 5 #import "ios/web/navigation/navigation_item_impl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #import "testing/gtest_mac.h" | 13 #import "testing/gtest_mac.h" |
14 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
15 | 15 |
16 namespace web { | 16 namespace web { |
17 namespace { | 17 namespace { |
18 | 18 |
19 const char kItemURLString[] = "http://init.test"; | 19 const char kItemURLString[] = "http://init.test"; |
20 static NSString* const kHTTPHeaderKey1 = @"key1"; | 20 static NSString* const kHTTPHeaderKey1 = @"key1"; |
21 static NSString* const kHTTPHeaderKey2 = @"key2"; | 21 static NSString* const kHTTPHeaderKey2 = @"key2"; |
(...skipping 16 matching lines...) Expand all Loading... | |
38 std::unique_ptr<NavigationItemImpl> item_; | 38 std::unique_ptr<NavigationItemImpl> item_; |
39 }; | 39 }; |
40 | 40 |
41 // TODO(rohitrao): Add and adapt tests from NavigationEntryImpl. | 41 // TODO(rohitrao): Add and adapt tests from NavigationEntryImpl. |
42 TEST_F(NavigationItemTest, Dummy) { | 42 TEST_F(NavigationItemTest, Dummy) { |
43 const GURL url("http://init.test"); | 43 const GURL url("http://init.test"); |
44 item_->SetURL(url); | 44 item_->SetURL(url); |
45 EXPECT_TRUE(item_->GetURL().is_valid()); | 45 EXPECT_TRUE(item_->GetURL().is_valid()); |
46 } | 46 } |
47 | 47 |
48 // Tests that the debug description is as expected. | |
49 TEST_F(NavigationItemTest, Description) { | |
50 item_->SetTitle(base::UTF8ToUTF16("Title")); | |
51 EXPECT_NSEQ(item_->GetDescription(), | |
Eugene But (OOO till 7-30)
2017/02/18 01:26:00
EXPECT_NSEQ takes first argument as expected value
kkhorimoto
2017/03/02 01:55:55
Done.
| |
52 @"url:http://init.test/ originalurl:http://init.test/ " | |
53 @"title:Title transition:2 displayState:{ scrollOffset:(nan, " | |
54 @"nan), zoomScaleRange:(nan, nan), zoomScale:nan } desktopUA:0"); | |
55 } | |
56 | |
48 // Tests that copied NavigationItemImpls create copies of data members that are | 57 // Tests that copied NavigationItemImpls create copies of data members that are |
49 // objects. | 58 // objects. |
50 TEST_F(NavigationItemTest, Copy) { | 59 TEST_F(NavigationItemTest, Copy) { |
51 // Create objects to be copied. | 60 // Create objects to be copied. |
52 NSString* postData0 = @"postData0"; | 61 NSString* postData0 = @"postData0"; |
53 NSMutableData* mutablePostData = | 62 NSMutableData* mutablePostData = |
54 [[postData0 dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]; | 63 [[postData0 dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]; |
55 item_->SetPostData(mutablePostData); | 64 item_->SetPostData(mutablePostData); |
56 NSString* state0 = @"state0"; | 65 NSString* state0 = @"state0"; |
57 NSMutableString* mutableState = [state0 mutableCopy]; | 66 NSMutableString* mutableState = [state0 mutableCopy]; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 EXPECT_EQ(original_url, item_->GetOriginalRequestURL()); | 126 EXPECT_EQ(original_url, item_->GetOriginalRequestURL()); |
118 web::NavigationItemImpl copy(*item_); | 127 web::NavigationItemImpl copy(*item_); |
119 GURL new_url = GURL("http://new_url.test"); | 128 GURL new_url = GURL("http://new_url.test"); |
120 item_->SetOriginalRequestURL(new_url); | 129 item_->SetOriginalRequestURL(new_url); |
121 EXPECT_EQ(new_url, item_->GetOriginalRequestURL()); | 130 EXPECT_EQ(new_url, item_->GetOriginalRequestURL()); |
122 EXPECT_EQ(original_url, copy.GetOriginalRequestURL()); | 131 EXPECT_EQ(original_url, copy.GetOriginalRequestURL()); |
123 } | 132 } |
124 | 133 |
125 } // namespace | 134 } // namespace |
126 } // namespace web | 135 } // namespace web |
OLD | NEW |