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

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

Issue 2901633002: Replaced NavigationContext::IsErrorPage with NavigationContext::GetError (Closed)
Patch Set: 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 #import "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"
11 11
12 namespace web { 12 namespace web {
13 namespace { 13 namespace {
14 const char kRawResponseHeaders[] = 14 const char kRawResponseHeaders[] =
15 "HTTP/1.1 200 OK\0" 15 "HTTP/1.1 200 OK\0"
(...skipping 16 matching lines...) Expand all
32 32
33 // Tests CreateNavigationContext factory method. 33 // Tests CreateNavigationContext factory method.
34 TEST_F(NavigationContextImplTest, NavigationContext) { 34 TEST_F(NavigationContextImplTest, NavigationContext) {
35 std::unique_ptr<NavigationContext> context = 35 std::unique_ptr<NavigationContext> context =
36 NavigationContextImpl::CreateNavigationContext(&web_state_, url_); 36 NavigationContextImpl::CreateNavigationContext(&web_state_, url_);
37 ASSERT_TRUE(context); 37 ASSERT_TRUE(context);
38 38
39 EXPECT_EQ(&web_state_, context->GetWebState()); 39 EXPECT_EQ(&web_state_, context->GetWebState());
40 EXPECT_EQ(url_, context->GetUrl()); 40 EXPECT_EQ(url_, context->GetUrl());
41 EXPECT_FALSE(context->IsSameDocument()); 41 EXPECT_FALSE(context->IsSameDocument());
42 EXPECT_FALSE(context->IsErrorPage()); 42 EXPECT_FALSE(context->GetError());
43 EXPECT_FALSE(context->GetResponseHeaders()); 43 EXPECT_FALSE(context->GetResponseHeaders());
44 } 44 }
45 45
46 // Tests NavigationContextImpl Setters. 46 // Tests NavigationContextImpl Setters.
47 TEST_F(NavigationContextImplTest, Setters) { 47 TEST_F(NavigationContextImplTest, Setters) {
48 std::unique_ptr<NavigationContextImpl> context = 48 std::unique_ptr<NavigationContextImpl> context =
49 NavigationContextImpl::CreateNavigationContext(&web_state_, url_); 49 NavigationContextImpl::CreateNavigationContext(&web_state_, url_);
50 ASSERT_TRUE(context); 50 ASSERT_TRUE(context);
51 51
52 ASSERT_FALSE(context->IsSameDocument()); 52 ASSERT_FALSE(context->IsSameDocument());
53 ASSERT_FALSE(context->IsErrorPage()); 53 ASSERT_FALSE(context->GetError());
54 ASSERT_NE(response_headers_.get(), context->GetResponseHeaders()); 54 ASSERT_NE(response_headers_.get(), context->GetResponseHeaders());
55 55
56 // SetSameDocument 56 // SetSameDocument
57 context->SetIsSameDocument(true); 57 context->SetIsSameDocument(true);
58 EXPECT_TRUE(context->IsSameDocument()); 58 EXPECT_TRUE(context->IsSameDocument());
59 EXPECT_FALSE(context->IsErrorPage()); 59 EXPECT_FALSE(context->GetError());
60 EXPECT_NE(response_headers_.get(), context->GetResponseHeaders()); 60 EXPECT_NE(response_headers_.get(), context->GetResponseHeaders());
61 61
62 // SetErrorPage 62 // SetErrorPage
63 context->SetIsErrorPage(true); 63 NSError* error = [[[NSError alloc] init] autorelease];
64 context->SetError(error);
64 EXPECT_TRUE(context->IsSameDocument()); 65 EXPECT_TRUE(context->IsSameDocument());
65 EXPECT_TRUE(context->IsErrorPage()); 66 EXPECT_EQ(error, context->GetError());
66 EXPECT_NE(response_headers_.get(), context->GetResponseHeaders()); 67 EXPECT_NE(response_headers_.get(), context->GetResponseHeaders());
67 68
68 // SetResponseHeaders 69 // SetResponseHeaders
69 context->SetResponseHeaders(response_headers_); 70 context->SetResponseHeaders(response_headers_);
70 EXPECT_TRUE(context->IsSameDocument()); 71 EXPECT_TRUE(context->IsSameDocument());
71 EXPECT_TRUE(context->IsErrorPage()); 72 EXPECT_EQ(error, context->GetError());
72 EXPECT_EQ(response_headers_.get(), context->GetResponseHeaders()); 73 EXPECT_EQ(response_headers_.get(), context->GetResponseHeaders());
73 } 74 }
74 75
75 } // namespace web 76 } // 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