Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: blimp/client/core/contents/blimp_contents_impl_unittest.cc

Issue 2058263002: Tied up BlimpNavigationController to NavigationFeature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blimp_core
Patch Set: kmarshall comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..4dc05f5808a55b9dc4d8eadac5d5843161ab9e37 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>
Kevin M 2016/08/01 23:41:58 Should use "" instead of <>, move into the second
shaktisahu 2016/08/02 17:47:52 Yes.. Eclipse refactoring.
#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 {
@@ -16,39 +18,39 @@ namespace {
const GURL kExampleURL = GURL("https://www.example.com/");
Kevin M 2016/08/01 23:41:58 Globals must be POD types e.g. const char[]
shaktisahu 2016/08/02 17:47:52 Done.
const GURL kOtherExampleURL = GURL("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) {
Kevin M 2016/08/01 23:41:58 Test name is too basic ;) RouteNavigationStateCha
shaktisahu 2016/08/02 17:47:52 Done.
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);
+ EXPECT_CALL(observer1, OnNavigationStateChanged());
+ 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 +59,6 @@ TEST(BlimpContentsImplTest, Basic) {
loop.RunUntilIdle();
EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL());
- EXPECT_EQ(kExampleURL, observer1.GetLastURL());
- EXPECT_EQ(kOtherExampleURL, observer2.GetLastURL());
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698