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

Side by Side Diff: Source/modules/screen_orientation/testing/ScreenOrientationClientMock.cpp

Issue 132113006: Add initial Blink-side support for the Screen Orientation API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add locked-no-orientation-change-event.html layout test Created 6 years, 10 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 | Annotate | Revision Log
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 "ScreenOrientationClientMock.h"
7
8 #include "modules/screen_orientation/ScreenOrientationController.h"
9
10 namespace WebCore {
11
12 ScreenOrientationClientMock::ScreenOrientationClientMock()
13 : m_controllerTimer(this, &ScreenOrientationClientMock::controllerTimerFired )
14 , m_controller(0)
15 , m_orientation(OrientationPortraitPrimary)
16 , m_lockedOrientations(0)
17 {
18 }
19
20 ScreenOrientationClientMock::~ScreenOrientationClientMock()
21 {
22 }
23
24 void ScreenOrientationClientMock::setController(ScreenOrientationController* con troller)
25 {
26 ASSERT(controller && !m_controller);
27 m_controller = controller;
28 }
29
30 void ScreenOrientationClientMock::setScreenOrientation(ScreenOrientationValue or ientation)
31 {
32 if (orientation == m_orientation)
33 return;
34
35 if (!m_lockedOrientations || m_lockedOrientations & orientation) {
36 m_orientation = orientation;
37 asyncUpdateController();
38 }
39 }
40
41 void ScreenOrientationClientMock::asyncUpdateController()
42 {
43 ASSERT(m_controller);
44 if (!m_controllerTimer.isActive())
45 m_controllerTimer.startOneShot(0);
46 }
47
48 void ScreenOrientationClientMock::controllerTimerFired(Timer<ScreenOrientationCl ientMock>* timer)
49 {
50 ASSERT_UNUSED(timer, timer == &m_controllerTimer);
51 ASSERT(m_controller);
52
53 m_controller->orientationChanged(m_orientation);
54 }
55
56 bool ScreenOrientationClientMock::lockOrientation(ScreenOrientationValues orient ations)
57 {
58 m_lockedOrientations = orientations;
mlamouri (slow - plz ping) 2014/02/10 18:20:57 Shouldn't you change the screen orientation asynch
Inactive 2014/02/10 22:25:24 You are right, I fixed it in a later iteration, bu
59 return true;
60 }
61
62 void ScreenOrientationClientMock::unlockOrientation()
63 {
64 m_lockedOrientations = 0;
65 }
66
67 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698