| 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 #include "ios/web/navigation/navigation_item_impl.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 5 #include "base/logging.h" | 9 #include "base/logging.h" |
| 6 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 7 #include "base/memory/scoped_ptr.h" | |
| 8 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 9 #include "ios/web/navigation/navigation_item_impl.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "testing/gtest_mac.h" | 13 #include "testing/gtest_mac.h" |
| 12 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
| 13 | 15 |
| 14 namespace web { | 16 namespace web { |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| 17 static NSString* const kHTTPHeaderKey1 = @"key1"; | 19 static NSString* const kHTTPHeaderKey1 = @"key1"; |
| 18 static NSString* const kHTTPHeaderKey2 = @"key2"; | 20 static NSString* const kHTTPHeaderKey2 = @"key2"; |
| 19 static NSString* const kHTTPHeaderValue1 = @"value1"; | 21 static NSString* const kHTTPHeaderValue1 = @"value1"; |
| 20 static NSString* const kHTTPHeaderValue2 = @"value2"; | 22 static NSString* const kHTTPHeaderValue2 = @"value2"; |
| 21 | 23 |
| 22 class NavigationItemTest : public PlatformTest { | 24 class NavigationItemTest : public PlatformTest { |
| 23 protected: | 25 protected: |
| 24 void SetUp() override { | 26 void SetUp() override { |
| 25 item_.reset(new web::NavigationItemImpl()); | 27 item_.reset(new web::NavigationItemImpl()); |
| 26 item_->SetURL(GURL("http://init.test")); | 28 item_->SetURL(GURL("http://init.test")); |
| 27 item_->SetTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 29 item_->SetTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 28 item_->SetTimestamp(base::Time::Now()); | 30 item_->SetTimestamp(base::Time::Now()); |
| 29 item_->AddHttpRequestHeaders(@{kHTTPHeaderKey1 : kHTTPHeaderValue1}); | 31 item_->AddHttpRequestHeaders(@{kHTTPHeaderKey1 : kHTTPHeaderValue1}); |
| 30 item_->SetPostData([@"Test data" dataUsingEncoding:NSUTF8StringEncoding]); | 32 item_->SetPostData([@"Test data" dataUsingEncoding:NSUTF8StringEncoding]); |
| 31 } | 33 } |
| 32 | 34 |
| 33 // The NavigationItemImpl instance being tested. | 35 // The NavigationItemImpl instance being tested. |
| 34 scoped_ptr<NavigationItemImpl> item_; | 36 std::unique_ptr<NavigationItemImpl> item_; |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 // TODO(rohitrao): Add and adapt tests from NavigationEntryImpl. | 39 // TODO(rohitrao): Add and adapt tests from NavigationEntryImpl. |
| 38 TEST_F(NavigationItemTest, Dummy) { | 40 TEST_F(NavigationItemTest, Dummy) { |
| 39 const GURL url("http://init.test"); | 41 const GURL url("http://init.test"); |
| 40 item_->SetURL(url); | 42 item_->SetURL(url); |
| 41 EXPECT_TRUE(item_->GetURL().is_valid()); | 43 EXPECT_TRUE(item_->GetURL().is_valid()); |
| 42 } | 44 } |
| 43 | 45 |
| 44 // Tests that copied NavigationItemImpls create copies of data members that are | 46 // Tests that copied NavigationItemImpls create copies of data members that are |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 item_->RemoveHttpRequestHeaderForKey(kHTTPHeaderKey1); | 104 item_->RemoveHttpRequestHeaderForKey(kHTTPHeaderKey1); |
| 103 EXPECT_NSEQ(@{kHTTPHeaderKey2 : kHTTPHeaderValue2}, | 105 EXPECT_NSEQ(@{kHTTPHeaderKey2 : kHTTPHeaderValue2}, |
| 104 item_->GetHttpRequestHeaders()); | 106 item_->GetHttpRequestHeaders()); |
| 105 | 107 |
| 106 item_->RemoveHttpRequestHeaderForKey(kHTTPHeaderKey2); | 108 item_->RemoveHttpRequestHeaderForKey(kHTTPHeaderKey2); |
| 107 EXPECT_FALSE(item_->GetHttpRequestHeaders()); | 109 EXPECT_FALSE(item_->GetHttpRequestHeaders()); |
| 108 } | 110 } |
| 109 | 111 |
| 110 } // namespace | 112 } // namespace |
| 111 } // namespace web | 113 } // namespace web |
| OLD | NEW |