| 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..555cbbe913ac298c31c00076895fe6a27a81a2c3 100644
|
| --- a/blimp/client/core/contents/blimp_contents_impl_unittest.cc
|
| +++ b/blimp/client/core/contents/blimp_contents_impl_unittest.cc
|
| @@ -6,59 +6,59 @@
|
|
|
| #include "base/message_loop/message_loop.h"
|
| #include "blimp/client/core/contents/blimp_contents_impl.h"
|
| +#include "blimp/client/core/contents/fake_navigation_feature.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 {
|
| namespace client {
|
| namespace {
|
|
|
| -const GURL kExampleURL = GURL("https://www.example.com/");
|
| -const GURL kOtherExampleURL = GURL("https://www.otherexample.com/");
|
| +const char kExampleURL[] = "https://www.example.com/";
|
| +const char kOtherExampleURL[] = "https://www.otherexample.com/";
|
|
|
| -class TestBlimpContentsObserver : public BlimpContentsObserver {
|
| +class MockBlimpContentsObserver : public BlimpContentsObserver {
|
| public:
|
| - TestBlimpContentsObserver() = default;
|
| - ~TestBlimpContentsObserver() override = default;
|
| + MockBlimpContentsObserver() = default;
|
| + ~MockBlimpContentsObserver() 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);
|
| + DISALLOW_COPY_AND_ASSIGN(MockBlimpContentsObserver);
|
| };
|
|
|
| -TEST(BlimpContentsImplTest, Basic) {
|
| +TEST(BlimpContentsImplTest, LoadURLAndNotifyObservers) {
|
| base::MessageLoop loop;
|
| BlimpContentsImpl blimp_contents;
|
|
|
| - BlimpNavigationController& navigation_controller =
|
| + BlimpNavigationControllerImpl& navigation_controller =
|
| blimp_contents.GetNavigationController();
|
| + FakeNavigationFeature feature;
|
| + feature.SetDelegate(1, &navigation_controller);
|
| + navigation_controller.SetNavigationFeatureForTesting(&feature);
|
|
|
| - TestBlimpContentsObserver observer1;
|
| + testing::StrictMock<MockBlimpContentsObserver> observer1;
|
| blimp_contents.AddObserver(&observer1);
|
| - TestBlimpContentsObserver observer2;
|
| + testing::StrictMock<MockBlimpContentsObserver> observer2;
|
| blimp_contents.AddObserver(&observer2);
|
|
|
| - navigation_controller.LoadURL(kExampleURL);
|
| + EXPECT_CALL(observer1, OnNavigationStateChanged());
|
| + EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2);
|
| +
|
| + navigation_controller.LoadURL(GURL(kExampleURL));
|
| loop.RunUntilIdle();
|
|
|
| - EXPECT_EQ(kExampleURL, navigation_controller.GetURL());
|
| - EXPECT_EQ(kExampleURL, observer1.GetLastURL());
|
| - EXPECT_EQ(kExampleURL, observer2.GetLastURL());
|
| + EXPECT_EQ(kExampleURL, navigation_controller.GetURL().spec());
|
|
|
| // Observer should no longer receive callbacks.
|
| blimp_contents.RemoveObserver(&observer1);
|
|
|
| - navigation_controller.LoadURL(kOtherExampleURL);
|
| + navigation_controller.LoadURL(GURL(kOtherExampleURL));
|
| loop.RunUntilIdle();
|
|
|
| - EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL());
|
| - EXPECT_EQ(kExampleURL, observer1.GetLastURL());
|
| - EXPECT_EQ(kOtherExampleURL, observer2.GetLastURL());
|
| + EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL().spec());
|
| }
|
|
|
| } // namespace
|
|
|