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..be006166e932a6260e2055942d829314def8574e 100644 |
| --- a/blimp/client/core/contents/blimp_navigation_controller_impl_unittest.cc |
| +++ b/blimp/client/core/contents/blimp_navigation_controller_impl_unittest.cc |
| @@ -2,13 +2,16 @@ |
| // 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> |
| #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 { |
| @@ -21,9 +24,7 @@ class TestBlimpNavigationControllerDelegate |
| TestBlimpNavigationControllerDelegate() = default; |
| ~TestBlimpNavigationControllerDelegate() override = default; |
| - void NotifyURLLoaded(const GURL& url) override { last_loaded_url_ = url; } |
| - |
| - GURL GetLastLoadedURL() { return last_loaded_url_; } |
| + MOCK_METHOD0(OnNavigationStateChanged, void()); |
| private: |
| GURL last_loaded_url_; |
|
Kevin M
2016/07/27 23:35:17
Not used?
shaktisahu
2016/07/28 19:32:51
Done.
|
| @@ -35,13 +36,24 @@ TEST(BlimpNavigationControllerImplTest, Basic) { |
| base::MessageLoop loop; |
| TestBlimpNavigationControllerDelegate delegate; |
| - BlimpNavigationControllerImpl navigation_controller(&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); |
|
Kevin M
2016/07/27 23:35:17
Times(1) is redundant; use StrictMock<>
shaktisahu
2016/07/28 19:32:51
Okay, didn't know much about StrictMock. There are
|
| + EXPECT_CALL(feature, GoForward(_)).Times(1); |
| + EXPECT_CALL(feature, Reload(_)).Times(1); |
| + |
| + navigation_controller.GoBack(); |
| + navigation_controller.GoForward(); |
| + navigation_controller.Reload(); |
| + |
| loop.RunUntilIdle(); |
| - EXPECT_EQ(kExampleURL, delegate.GetLastLoadedURL()); |
| } |
| } // namespace |