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

Side by Side Diff: ios/web/web_state/navigation_context_impl_unittest.mm

Issue 2845913003: Cleaned up unused methods from WebStateImpl and NavigationContextImpl. (Closed)
Patch Set: Fixed tests Created 3 years, 7 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/web_state/navigation_context_impl.h" 5 #include "ios/web/web_state/navigation_context_impl.h"
6 6
7 #import "ios/web/public/test/fakes/test_web_state.h" 7 #import "ios/web/public/test/fakes/test_web_state.h"
8 #include "net/http/http_response_headers.h" 8 #include "net/http/http_response_headers.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
(...skipping 12 matching lines...) Expand all
23 NavigationContextImplTest() 23 NavigationContextImplTest()
24 : url_("https://chromium.test"), 24 : url_("https://chromium.test"),
25 response_headers_(new net::HttpResponseHeaders( 25 response_headers_(new net::HttpResponseHeaders(
26 std::string(kRawResponseHeaders, sizeof(kRawResponseHeaders)))) {} 26 std::string(kRawResponseHeaders, sizeof(kRawResponseHeaders)))) {}
27 27
28 TestWebState web_state_; 28 TestWebState web_state_;
29 GURL url_; 29 GURL url_;
30 scoped_refptr<net::HttpResponseHeaders> response_headers_; 30 scoped_refptr<net::HttpResponseHeaders> response_headers_;
31 }; 31 };
32 32
33 // Tests legacy CreateNavigationContext factory method.
34 TEST_F(NavigationContextImplTest, LegacyNavigationContext) {
35 std::unique_ptr<NavigationContext> context =
36 NavigationContextImpl::CreateNavigationContext(&web_state_, url_,
37 response_headers_);
38 ASSERT_TRUE(context);
39
40 EXPECT_EQ(&web_state_, context->GetWebState());
41 EXPECT_EQ(url_, context->GetUrl());
42 EXPECT_FALSE(context->IsSameDocument());
43 EXPECT_FALSE(context->IsErrorPage());
44 EXPECT_EQ(response_headers_.get(), context->GetResponseHeaders());
45 }
46
47 // Tests CreateNavigationContext factory method. 33 // Tests CreateNavigationContext factory method.
48 TEST_F(NavigationContextImplTest, NavigationContext) { 34 TEST_F(NavigationContextImplTest, NavigationContext) {
49 std::unique_ptr<NavigationContext> context = 35 std::unique_ptr<NavigationContext> context =
50 NavigationContextImpl::CreateNavigationContext(&web_state_, url_); 36 NavigationContextImpl::CreateNavigationContext(&web_state_, url_);
51 ASSERT_TRUE(context); 37 ASSERT_TRUE(context);
52 38
53 EXPECT_EQ(&web_state_, context->GetWebState()); 39 EXPECT_EQ(&web_state_, context->GetWebState());
54 EXPECT_EQ(url_, context->GetUrl()); 40 EXPECT_EQ(url_, context->GetUrl());
55 EXPECT_FALSE(context->IsSameDocument()); 41 EXPECT_FALSE(context->IsSameDocument());
56 EXPECT_FALSE(context->IsErrorPage()); 42 EXPECT_FALSE(context->IsErrorPage());
57 EXPECT_FALSE(context->GetResponseHeaders()); 43 EXPECT_FALSE(context->GetResponseHeaders());
58 } 44 }
59 45
60 // Tests CreateSameDocumentNavigationContext factory method.
61 TEST_F(NavigationContextImplTest, SameDocumentNavigationContext) {
62 std::unique_ptr<NavigationContext> context =
63 NavigationContextImpl::CreateSameDocumentNavigationContext(&web_state_,
64 url_);
65 ASSERT_TRUE(context);
66
67 EXPECT_EQ(&web_state_, context->GetWebState());
68 EXPECT_EQ(url_, context->GetUrl());
69 EXPECT_TRUE(context->IsSameDocument());
70 EXPECT_FALSE(context->IsErrorPage());
71 EXPECT_FALSE(context->GetResponseHeaders());
72 }
73
74 // Tests CreateErrorPageNavigationContext factory method.
75 TEST_F(NavigationContextImplTest, ErrorPageNavigationContext) {
76 std::unique_ptr<NavigationContext> context =
77 NavigationContextImpl::CreateErrorPageNavigationContext(
78 &web_state_, url_, response_headers_);
79 ASSERT_TRUE(context);
80
81 EXPECT_EQ(&web_state_, context->GetWebState());
82 EXPECT_EQ(url_, context->GetUrl());
83 EXPECT_FALSE(context->IsSameDocument());
84 EXPECT_TRUE(context->IsErrorPage());
85 EXPECT_EQ(response_headers_.get(), context->GetResponseHeaders());
86 }
87
88 // Tests NavigationContextImpl Setters. 46 // Tests NavigationContextImpl Setters.
89 TEST_F(NavigationContextImplTest, Setters) { 47 TEST_F(NavigationContextImplTest, Setters) {
90 std::unique_ptr<NavigationContextImpl> context = 48 std::unique_ptr<NavigationContextImpl> context =
91 NavigationContextImpl::CreateNavigationContext(&web_state_, url_); 49 NavigationContextImpl::CreateNavigationContext(&web_state_, url_);
92 ASSERT_TRUE(context); 50 ASSERT_TRUE(context);
93 51
94 ASSERT_FALSE(context->IsSameDocument()); 52 ASSERT_FALSE(context->IsSameDocument());
95 ASSERT_FALSE(context->IsErrorPage()); 53 ASSERT_FALSE(context->IsErrorPage());
96 ASSERT_NE(response_headers_.get(), context->GetResponseHeaders()); 54 ASSERT_NE(response_headers_.get(), context->GetResponseHeaders());
97 55
(...skipping 10 matching lines...) Expand all
108 EXPECT_NE(response_headers_.get(), context->GetResponseHeaders()); 66 EXPECT_NE(response_headers_.get(), context->GetResponseHeaders());
109 67
110 // SetResponseHeaders 68 // SetResponseHeaders
111 context->SetResponseHeaders(response_headers_); 69 context->SetResponseHeaders(response_headers_);
112 EXPECT_TRUE(context->IsSameDocument()); 70 EXPECT_TRUE(context->IsSameDocument());
113 EXPECT_TRUE(context->IsErrorPage()); 71 EXPECT_TRUE(context->IsErrorPage());
114 EXPECT_EQ(response_headers_.get(), context->GetResponseHeaders()); 72 EXPECT_EQ(response_headers_.get(), context->GetResponseHeaders());
115 } 73 }
116 74
117 } // namespace web 75 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/web_state/navigation_context_impl.mm ('k') | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698