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

Unified Diff: Source/core/frame/ViewportChangeNotifierTest.cpp

Issue 369423002: Have srcset respond to viewport changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Self review nits Created 6 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: Source/core/frame/ViewportChangeNotifierTest.cpp
diff --git a/Source/core/frame/ViewportChangeNotifierTest.cpp b/Source/core/frame/ViewportChangeNotifierTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d285e4e63b0ba450ef3acb087e3cbbde382987ef
--- /dev/null
+++ b/Source/core/frame/ViewportChangeNotifierTest.cpp
@@ -0,0 +1,50 @@
+// Copyright 2014 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 "config.h"
+#include "core/frame/ViewportChangeNotifier.h"
+
+#include <gtest/gtest.h>
+
+namespace WebCore {
+
+class TestListener: public ViewportChangeListener {
+public:
+ static PassRefPtrWillBeRawPtr<TestListener> create() { return adoptRefWillBeNoop(new TestListener()); }
+
+ void viewportChanged()
+ {
+ m_listenerCalled = true;
+ }
+
+ TestListener()
+ : m_listenerCalled(false)
+ {
+ }
+
+ bool called() const { return m_listenerCalled; }
+
+private:
+ bool m_listenerCalled;
+};
+
+TEST(ViewportChangeNotifierTest, Basic)
+{
+ OwnPtrWillBeRawPtr<ViewportChangeNotifier> notifier = ViewportChangeNotifier::create();
+ RefPtrWillBeRawPtr<TestListener> listener = TestListener::create();
+ notifier->addListener(listener);
+ ASSERT_FALSE(listener->called());
+ notifier->viewportChanged();
+ ASSERT_TRUE(listener->called());
+
+ RefPtrWillBeRawPtr<TestListener> listener2 = TestListener::create();
+ notifier->addListener(listener2);
+ ASSERT_FALSE(listener2->called());
+ notifier->removeListener(listener2);
+ notifier->viewportChanged();
+ ASSERT_FALSE(listener2->called());
+}
+
+} // namespace
+

Powered by Google App Engine
This is Rietveld 408576698