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

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

Issue 2896623003: Added web::NavigationContext::GetPageTransition. (Closed)
Patch Set: Rebased 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 #import "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"
(...skipping 15 matching lines...) Expand all
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 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(
37 &web_state_, url_, ui::PageTransition::PAGE_TRANSITION_FORWARD_BACK);
37 ASSERT_TRUE(context); 38 ASSERT_TRUE(context);
38 39
39 EXPECT_EQ(&web_state_, context->GetWebState()); 40 EXPECT_EQ(&web_state_, context->GetWebState());
41 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs(
42 context->GetPageTransition(),
43 ui::PageTransition::PAGE_TRANSITION_FORWARD_BACK));
40 EXPECT_EQ(url_, context->GetUrl()); 44 EXPECT_EQ(url_, context->GetUrl());
41 EXPECT_FALSE(context->IsSameDocument()); 45 EXPECT_FALSE(context->IsSameDocument());
42 EXPECT_FALSE(context->GetError()); 46 EXPECT_FALSE(context->GetError());
43 EXPECT_FALSE(context->GetResponseHeaders()); 47 EXPECT_FALSE(context->GetResponseHeaders());
44 } 48 }
45 49
46 // Tests NavigationContextImpl Setters. 50 // Tests NavigationContextImpl Setters.
47 TEST_F(NavigationContextImplTest, Setters) { 51 TEST_F(NavigationContextImplTest, Setters) {
48 std::unique_ptr<NavigationContextImpl> context = 52 std::unique_ptr<NavigationContextImpl> context =
49 NavigationContextImpl::CreateNavigationContext(&web_state_, url_); 53 NavigationContextImpl::CreateNavigationContext(
54 &web_state_, url_, ui::PageTransition::PAGE_TRANSITION_FORWARD_BACK);
50 ASSERT_TRUE(context); 55 ASSERT_TRUE(context);
51 56
52 ASSERT_FALSE(context->IsSameDocument()); 57 ASSERT_FALSE(context->IsSameDocument());
53 ASSERT_FALSE(context->GetError()); 58 ASSERT_FALSE(context->GetError());
54 ASSERT_NE(response_headers_.get(), context->GetResponseHeaders()); 59 ASSERT_NE(response_headers_.get(), context->GetResponseHeaders());
55 60
56 // SetSameDocument 61 // SetSameDocument
57 context->SetIsSameDocument(true); 62 context->SetIsSameDocument(true);
58 EXPECT_TRUE(context->IsSameDocument()); 63 EXPECT_TRUE(context->IsSameDocument());
59 EXPECT_FALSE(context->GetError()); 64 EXPECT_FALSE(context->GetError());
60 EXPECT_NE(response_headers_.get(), context->GetResponseHeaders()); 65 EXPECT_NE(response_headers_.get(), context->GetResponseHeaders());
61 66
62 // SetErrorPage 67 // SetErrorPage
63 NSError* error = [[[NSError alloc] init] autorelease]; 68 NSError* error = [[[NSError alloc] init] autorelease];
64 context->SetError(error); 69 context->SetError(error);
65 EXPECT_TRUE(context->IsSameDocument()); 70 EXPECT_TRUE(context->IsSameDocument());
66 EXPECT_EQ(error, context->GetError()); 71 EXPECT_EQ(error, context->GetError());
67 EXPECT_NE(response_headers_.get(), context->GetResponseHeaders()); 72 EXPECT_NE(response_headers_.get(), context->GetResponseHeaders());
68 73
69 // SetResponseHeaders 74 // SetResponseHeaders
70 context->SetResponseHeaders(response_headers_); 75 context->SetResponseHeaders(response_headers_);
71 EXPECT_TRUE(context->IsSameDocument()); 76 EXPECT_TRUE(context->IsSameDocument());
72 EXPECT_EQ(error, context->GetError()); 77 EXPECT_EQ(error, context->GetError());
73 EXPECT_EQ(response_headers_.get(), context->GetResponseHeaders()); 78 EXPECT_EQ(response_headers_.get(), context->GetResponseHeaders());
74 } 79 }
75 80
76 } // namespace web 81 } // 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