| 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..02fc86aeb35d880dae5e119dbce4a3aa05818f7f 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,55 @@
|
| // 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/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 "blimp/client/core/contents/blimp_navigation_controller_impl.h"
|
| +#include "blimp/client/core/contents/fake_navigation_feature.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) {
|
| +TEST(BlimpNavigationControllerImplTest, BackForwardNavigation) {
|
| base::MessageLoop loop;
|
|
|
| - TestBlimpNavigationControllerDelegate delegate;
|
| - BlimpNavigationControllerImpl navigation_controller(&delegate);
|
| + testing::StrictMock<MockBlimpNavigationControllerDelegate> delegate;
|
| + testing::StrictMock<FakeNavigationFeature> feature;
|
| + BlimpNavigationControllerImpl navigation_controller(&delegate, &feature);
|
| + feature.SetDelegate(1, &navigation_controller);
|
| +
|
| + EXPECT_CALL(delegate, OnNavigationStateChanged());
|
|
|
| navigation_controller.LoadURL(kExampleURL);
|
| EXPECT_EQ(kExampleURL, navigation_controller.GetURL());
|
|
|
| + EXPECT_CALL(feature, GoBack(_));
|
| + EXPECT_CALL(feature, GoForward(_));
|
| + EXPECT_CALL(feature, Reload(_));
|
| +
|
| + navigation_controller.GoBack();
|
| + navigation_controller.GoForward();
|
| + navigation_controller.Reload();
|
| +
|
| loop.RunUntilIdle();
|
| - EXPECT_EQ(kExampleURL, delegate.GetLastLoadedURL());
|
| }
|
|
|
| } // namespace
|
|
|