1 /* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 * 19 */ 20 #include "config.h" 21 #include "DeviceOrientationClientMockQt.h" 22 23 #include "DeviceOrientation.h" 24 #include "DeviceOrientationClientMock.h" 25 #include "DeviceOrientationController.h" 26 27 namespace WebCore { 28 29 bool DeviceOrientationClientMockQt::mockIsActive = false; 30 31 DeviceOrientationClientMockQt* DeviceOrientationClientMockQt::client() 32 { 33 static DeviceOrientationClientMockQt* client = 0; 34 if (!client) 35 client = new DeviceOrientationClientMockQt; 36 37 return client; 38 } 39 40 DeviceOrientationClientMockQt::DeviceOrientationClientMockQt() 41 : m_clientMock(new DeviceOrientationClientMock()) 42 { 43 m_orientation = DeviceOrientation::create(); 44 } 45 46 DeviceOrientationClientMockQt::~DeviceOrientationClientMockQt() 47 { 48 delete m_clientMock; 49 } 50 51 void DeviceOrientationClientMockQt::setController(DeviceOrientationController* controller) 52 { 53 m_clientMock->setController(m_controller); 54 } 55 56 void DeviceOrientationClientMockQt::startUpdating() 57 { 58 m_clientMock->startUpdating(); 59 } 60 61 void DeviceOrientationClientMockQt::stopUpdating() 62 { 63 m_clientMock->stopUpdating(); 64 } 65 66 DeviceOrientation* DeviceOrientationClientMockQt::lastOrientation() const 67 { 68 return m_orientation.get(); 69 } 70 71 void DeviceOrientationClientMockQt::deviceOrientationControllerDestroyed() 72 { 73 delete this; 74 } 75 76 void DeviceOrientationClientMockQt::setOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma) 77 { 78 m_orientation = DeviceOrientation::create(canProvideAlpha, alpha, 79 canProvideBeta, beta, 80 canProvideGamma, gamma); 81 m_clientMock->setOrientation(m_orientation); 82 83 emit mockOrientationChanged(m_orientation.get()); 84 } 85 86 } // namespace WebCore 87 88 #include "moc_DeviceOrientationClientMockQt.cpp" 89