Chromium Code Reviews| Index: ios/web/web_state/navigation_context_impl_unittest.mm |
| diff --git a/ios/web/web_state/navigation_context_impl_unittest.mm b/ios/web/web_state/navigation_context_impl_unittest.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..87154cb5a7b5ff703a5efd3146ccd07c6ef64df6 |
| --- /dev/null |
| +++ b/ios/web/web_state/navigation_context_impl_unittest.mm |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ios/web/web_state/navigation_context_impl.h" |
| + |
| +#import "ios/web/public/test/fakes/test_web_state.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "testing/platform_test.h" |
| + |
| +namespace web { |
| + |
| +// Test fixture for NavigationContextImplTest testing. |
| +class PlatformTestNavigationContextImplTest : public PlatformTest { |
|
rohitrao (ping after 24h)
2017/02/24 01:22:48
Could this fixture go into an anonymous namespace
Eugene But (OOO till 7-30)
2017/02/24 01:49:41
Fixed fixture name, that was a mistake.
As for an
|
| + protected: |
| + PlatformTestNavigationContextImplTest() : url_("https://chromium.test") {} |
| + |
| + TestWebState web_state_; |
| + GURL url_; |
| +}; |
| + |
| +// Tests CreateNavigationContext factory method. |
| +TEST_F(PlatformTestNavigationContextImplTest, NavigationContext) { |
| + std::unique_ptr<NavigationContext> context = |
| + NavigationContextImpl::CreateNavigationContext(&web_state_, url_); |
| + ASSERT_TRUE(context); |
| + |
| + EXPECT_EQ(&web_state_, context->GetWebState()); |
| + EXPECT_EQ(url_, context->GetUrl()); |
| + EXPECT_FALSE(context->IsSamePage()); |
| + EXPECT_FALSE(context->IsErrorPage()); |
| +} |
| + |
| +// Tests CreateSamePageNavigationContext factory method. |
| +TEST_F(PlatformTestNavigationContextImplTest, SamePageNavigationContext) { |
| + std::unique_ptr<NavigationContext> context = |
| + NavigationContextImpl::CreateSamePageNavigationContext(&web_state_, url_); |
| + ASSERT_TRUE(context); |
| + |
| + EXPECT_EQ(&web_state_, context->GetWebState()); |
| + EXPECT_EQ(url_, context->GetUrl()); |
| + EXPECT_TRUE(context->IsSamePage()); |
| + EXPECT_FALSE(context->IsErrorPage()); |
| +} |
| + |
| +// Tests CreateErrorPageNavigationContext factory method. |
| +TEST_F(PlatformTestNavigationContextImplTest, ErrorPageNavigationContext) { |
| + std::unique_ptr<NavigationContext> context = |
| + NavigationContextImpl::CreateErrorPageNavigationContext(&web_state_, |
| + url_); |
| + ASSERT_TRUE(context); |
| + |
| + EXPECT_EQ(&web_state_, context->GetWebState()); |
| + EXPECT_EQ(url_, context->GetUrl()); |
| + EXPECT_FALSE(context->IsSamePage()); |
| + EXPECT_TRUE(context->IsErrorPage()); |
| +} |
| + |
| +} // namespace web |