| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ios/web/web_state/navigation_handle_impl.h" |
| 6 |
| 7 #import "ios/web/public/test/fakes/test_web_state.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "testing/platform_test.h" |
| 10 |
| 11 namespace web { |
| 12 |
| 13 // Test fixture for NavigationHandleImplTest testing. |
| 14 class PlatformTestNavigationHandleImplTest : public PlatformTest { |
| 15 protected: |
| 16 PlatformTestNavigationHandleImplTest() : url_("https://chromium.test") {} |
| 17 |
| 18 TestWebState web_state_; |
| 19 GURL url_; |
| 20 }; |
| 21 |
| 22 // Tests CreateNavigationHandle factory method. |
| 23 TEST_F(PlatformTestNavigationHandleImplTest, NavigationHandle) { |
| 24 std::unique_ptr<NavigationHandle> handle = |
| 25 NavigationHandleImpl::CreateNavigationHandle(&web_state_, url_); |
| 26 ASSERT_TRUE(handle); |
| 27 |
| 28 EXPECT_EQ(&web_state_, handle->GetWebState()); |
| 29 EXPECT_EQ(url_, handle->GetUrl()); |
| 30 EXPECT_FALSE(handle->IsSamePage()); |
| 31 EXPECT_FALSE(handle->IsErrorPage()); |
| 32 } |
| 33 |
| 34 // Tests CreateSamePageNavigationHandle factory method. |
| 35 TEST_F(PlatformTestNavigationHandleImplTest, SamePageNavigationHandle) { |
| 36 std::unique_ptr<NavigationHandle> handle = |
| 37 NavigationHandleImpl::CreateSamePageNavigationHandle(&web_state_, url_); |
| 38 ASSERT_TRUE(handle); |
| 39 |
| 40 EXPECT_EQ(&web_state_, handle->GetWebState()); |
| 41 EXPECT_EQ(url_, handle->GetUrl()); |
| 42 EXPECT_TRUE(handle->IsSamePage()); |
| 43 EXPECT_FALSE(handle->IsErrorPage()); |
| 44 } |
| 45 |
| 46 // Tests CreateErrorPageNavigationHandle factory method. |
| 47 TEST_F(PlatformTestNavigationHandleImplTest, ErrorPageNavigationHandle) { |
| 48 std::unique_ptr<NavigationHandle> handle = |
| 49 NavigationHandleImpl::CreateErrorPageNavigationHandle(&web_state_, url_); |
| 50 ASSERT_TRUE(handle); |
| 51 |
| 52 EXPECT_EQ(&web_state_, handle->GetWebState()); |
| 53 EXPECT_EQ(url_, handle->GetUrl()); |
| 54 EXPECT_FALSE(handle->IsSamePage()); |
| 55 EXPECT_TRUE(handle->IsErrorPage()); |
| 56 } |
| 57 |
| 58 } // namespace web |
| OLD | NEW |