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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/frame/ViewportChangeNotifier.h"
7
8 #include <gtest/gtest.h>
9
10 namespace WebCore {
11
12 class TestListener: public ViewportChangeListener {
13 public:
14 static PassRefPtrWillBeRawPtr<TestListener> create() { return adoptRefWillBe Noop(new TestListener()); }
15
16 void viewportChanged()
17 {
18 m_listenerCalled = true;
19 }
20
21 TestListener()
22 : m_listenerCalled(false)
23 {
24 }
25
26 bool called() const { return m_listenerCalled; }
27
28 private:
29 bool m_listenerCalled;
30 };
31
32 TEST(ViewportChangeNotifierTest, Basic)
33 {
34 OwnPtrWillBeRawPtr<ViewportChangeNotifier> notifier = ViewportChangeNotifier ::create();
35 RefPtrWillBeRawPtr<TestListener> listener = TestListener::create();
36 notifier->addListener(listener);
37 ASSERT_FALSE(listener->called());
38 notifier->viewportChanged();
39 ASSERT_TRUE(listener->called());
40
41 RefPtrWillBeRawPtr<TestListener> listener2 = TestListener::create();
42 notifier->addListener(listener2);
43 ASSERT_FALSE(listener2->called());
44 notifier->removeListener(listener2);
45 notifier->viewportChanged();
46 ASSERT_FALSE(listener2->called());
47 }
48
49 } // namespace
50
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698