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

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

Issue 2040813004: Add BlimpContents[,Observer] and BlimpNavigationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git merge origin/master Created 4 years, 6 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
« no previous file with comments | « blimp/client/core/blimp_contents_impl.cc ('k') | blimp/client/core/blimp_navigation_controller_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/client/core/blimp_contents_impl_unittest.cc
diff --git a/blimp/client/core/blimp_contents_impl_unittest.cc b/blimp/client/core/blimp_contents_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3d4a7c0aea665325a069fb9b56ce9c21100bcd74
--- /dev/null
+++ b/blimp/client/core/blimp_contents_impl_unittest.cc
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "blimp/client/core/blimp_contents_impl.h"
+
+#include "base/message_loop/message_loop.h"
+#include "blimp/client/core/blimp_contents_impl.h"
+#include "blimp/client/core/public/blimp_contents_observer.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/");
+
+class TestBlimpContentsObserver : public BlimpContentsObserver {
+ public:
+ TestBlimpContentsObserver() = default;
+ ~TestBlimpContentsObserver() override = default;
+
+ void OnURLUpdated(const GURL& url) override { last_url_ = url; }
+
+ GURL GetLastURL() { return last_url_; }
+
+ private:
+ GURL last_url_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestBlimpContentsObserver);
+};
+
+TEST(BlimpContentsImplTest, Basic) {
+ base::MessageLoop loop;
+ BlimpContentsImpl blimp_contents;
+
+ BlimpNavigationController& navigation_controller =
+ blimp_contents.GetNavigationController();
+
+ TestBlimpContentsObserver observer1;
+ blimp_contents.AddObserver(&observer1);
+ TestBlimpContentsObserver observer2;
+ blimp_contents.AddObserver(&observer2);
+
+ 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);
+
+ navigation_controller.LoadURL(kOtherExampleURL);
+ loop.RunUntilIdle();
+
+ EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL());
+ EXPECT_EQ(kExampleURL, observer1.GetLastURL());
+ EXPECT_EQ(kOtherExampleURL, observer2.GetLastURL());
+}
+
+} // namespace
+} // namespace client
+} // namespace blimp
« no previous file with comments | « blimp/client/core/blimp_contents_impl.cc ('k') | blimp/client/core/blimp_navigation_controller_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698