Chromium Code Reviews| Index: blimp/client/core/contents/blimp_navigation_controller_impl_unittest.cc |
| diff --git a/blimp/client/core/contents/blimp_navigation_controller_impl_unittest.cc b/blimp/client/core/contents/blimp_navigation_controller_impl_unittest.cc |
| index b219b383430b6d7ecca01f2065f62a70a2d8b482..840d199cd643da57ef5768bb1b1241505877e3a1 100644 |
| --- a/blimp/client/core/contents/blimp_navigation_controller_impl_unittest.cc |
| +++ b/blimp/client/core/contents/blimp_navigation_controller_impl_unittest.cc |
| @@ -2,46 +2,56 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <blimp/client/core/contents/fake_navigation_feature.h> |
|
Kevin M
2016/07/29 21:05:32
Don't use <> for non-system includes
|
| #include "blimp/client/core/contents/blimp_navigation_controller_impl.h" |
| -#include "base/macros.h" |
| #include "base/message_loop/message_loop.h" |
| #include "blimp/client/core/contents/blimp_navigation_controller_delegate.h" |
| +#include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +using testing::_; |
| + |
| namespace blimp { |
| namespace client { |
| namespace { |
| const GURL kExampleURL = GURL("https://www.example.com/"); |
| -class TestBlimpNavigationControllerDelegate |
| +class MockBlimpNavigationControllerDelegate |
| : public BlimpNavigationControllerDelegate { |
| public: |
| - TestBlimpNavigationControllerDelegate() = default; |
| - ~TestBlimpNavigationControllerDelegate() override = default; |
| - |
| - void NotifyURLLoaded(const GURL& url) override { last_loaded_url_ = url; } |
| + MockBlimpNavigationControllerDelegate() = default; |
| + ~MockBlimpNavigationControllerDelegate() override = default; |
| - GURL GetLastLoadedURL() { return last_loaded_url_; } |
| + MOCK_METHOD0(OnNavigationStateChanged, void()); |
| private: |
| - GURL last_loaded_url_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(TestBlimpNavigationControllerDelegate); |
| + DISALLOW_COPY_AND_ASSIGN(MockBlimpNavigationControllerDelegate); |
| }; |
| TEST(BlimpNavigationControllerImplTest, Basic) { |
| base::MessageLoop loop; |
| - TestBlimpNavigationControllerDelegate delegate; |
| - BlimpNavigationControllerImpl navigation_controller(&delegate); |
| + MockBlimpNavigationControllerDelegate delegate; |
| + FakeNavigationFeature feature; |
| + BlimpNavigationControllerImpl navigation_controller(&delegate, &feature); |
| + feature.SetDelegate(1, &navigation_controller); |
| + |
| + EXPECT_CALL(delegate, OnNavigationStateChanged()).Times(1); |
| navigation_controller.LoadURL(kExampleURL); |
| EXPECT_EQ(kExampleURL, navigation_controller.GetURL()); |
| + EXPECT_CALL(feature, GoBack(_)).Times(1); |
| + EXPECT_CALL(feature, GoForward(_)).Times(1); |
|
Kevin M
2016/07/29 21:05:32
Use StrictMock; remove Times(1)
shaktisahu
2016/07/29 22:57:30
Done.
|
| + EXPECT_CALL(feature, Reload(_)).Times(1); |
| + |
| + navigation_controller.GoBack(); |
| + navigation_controller.GoForward(); |
| + navigation_controller.Reload(); |
| + |
| loop.RunUntilIdle(); |
| - EXPECT_EQ(kExampleURL, delegate.GetLastLoadedURL()); |
| } |
| } // namespace |