| Index: blimp/client/core/contents/blimp_contents_impl_unittest.cc
|
| diff --git a/blimp/client/core/contents/blimp_contents_impl_unittest.cc b/blimp/client/core/contents/blimp_contents_impl_unittest.cc
|
| index 03132529690813afa33bd0e4797b8de48480e449..027514f016aa2e02cd7e89efe19de22a44b6396e 100644
|
| --- a/blimp/client/core/contents/blimp_contents_impl_unittest.cc
|
| +++ b/blimp/client/core/contents/blimp_contents_impl_unittest.cc
|
| @@ -2,11 +2,13 @@
|
| // 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_contents_impl.h"
|
|
|
| #include "base/message_loop/message_loop.h"
|
| #include "blimp/client/core/contents/blimp_contents_impl.h"
|
| #include "blimp/client/public/contents/blimp_contents_observer.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace blimp {
|
| @@ -21,21 +23,18 @@ class TestBlimpContentsObserver : public BlimpContentsObserver {
|
| TestBlimpContentsObserver() = default;
|
| ~TestBlimpContentsObserver() override = default;
|
|
|
| - void OnURLUpdated(const GURL& url) override { last_url_ = url; }
|
| -
|
| - GURL GetLastURL() { return last_url_; }
|
| + MOCK_METHOD0(OnNavigationStateChanged, void());
|
|
|
| private:
|
| - GURL last_url_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(TestBlimpContentsObserver);
|
| };
|
|
|
| TEST(BlimpContentsImplTest, Basic) {
|
| base::MessageLoop loop;
|
| BlimpContentsImpl blimp_contents;
|
| + FakeNavigationFeature feature;
|
|
|
| - BlimpNavigationController& navigation_controller =
|
| + BlimpNavigationControllerImpl& navigation_controller =
|
| blimp_contents.GetNavigationController();
|
|
|
| TestBlimpContentsObserver observer1;
|
| @@ -43,12 +42,16 @@ TEST(BlimpContentsImplTest, Basic) {
|
| TestBlimpContentsObserver observer2;
|
| blimp_contents.AddObserver(&observer2);
|
|
|
| + feature.SetDelegate(1, &navigation_controller);
|
| + navigation_controller.SetNavigationFeatureForTesting(&feature);
|
| +
|
| + EXPECT_CALL(observer1, OnNavigationStateChanged()).Times(1);
|
| + EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2);
|
| +
|
| navigation_controller.LoadURL(kExampleURL);
|
| loop.RunUntilIdle();
|
|
|
| EXPECT_EQ(kExampleURL, navigation_controller.GetURL());
|
| - EXPECT_EQ(kExampleURL, observer1.GetLastURL());
|
| - EXPECT_EQ(kExampleURL, observer2.GetLastURL());
|
|
|
| // Observer should no longer receive callbacks.
|
| blimp_contents.RemoveObserver(&observer1);
|
| @@ -57,8 +60,6 @@ TEST(BlimpContentsImplTest, Basic) {
|
| loop.RunUntilIdle();
|
|
|
| EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL());
|
| - EXPECT_EQ(kExampleURL, observer1.GetLastURL());
|
| - EXPECT_EQ(kOtherExampleURL, observer2.GetLastURL());
|
| }
|
|
|
| } // namespace
|
|
|