LCOV - code coverage report
Current view: top level - dom/gamepad/ipc - GamepadTestChannelParent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 40 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       3             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : #include "GamepadTestChannelParent.h"
       6             : 
       7             : #include "mozilla/dom/GamepadPlatformService.h"
       8             : #include "mozilla/Unused.h"
       9             : 
      10             : namespace mozilla {
      11             : namespace dom {
      12             : 
      13             : mozilla::ipc::IPCResult
      14           0 : GamepadTestChannelParent::RecvGamepadTestEvent(const uint32_t& aID,
      15             :                                                const GamepadChangeEvent& aEvent)
      16             : {
      17           0 :   mozilla::ipc::AssertIsOnBackgroundThread();
      18             :   RefPtr<GamepadPlatformService>  service =
      19           0 :     GamepadPlatformService::GetParentService();
      20           0 :   MOZ_ASSERT(service);
      21           0 :   if (aEvent.type() == GamepadChangeEvent::TGamepadAdded) {
      22           0 :     const GamepadAdded& a = aEvent.get_GamepadAdded();
      23           0 :     nsCString gamepadID;
      24           0 :     LossyCopyUTF16toASCII(a.id(), gamepadID);
      25           0 :     uint32_t index = service->AddGamepad(gamepadID.get(),
      26           0 :                                          static_cast<GamepadMappingType>(a.mapping()),
      27           0 :                                          a.hand(),
      28           0 :                                          a.num_buttons(),
      29           0 :                                          a.num_axes(),
      30           0 :                                          a.num_haptics());
      31           0 :     if (!mShuttingdown) {
      32           0 :       Unused << SendReplyGamepadIndex(aID, index);
      33             :     }
      34           0 :     return IPC_OK();
      35             :   }
      36           0 :   if (aEvent.type() == GamepadChangeEvent::TGamepadRemoved) {
      37           0 :     const GamepadRemoved& a = aEvent.get_GamepadRemoved();
      38           0 :     service->RemoveGamepad(a.index());
      39           0 :     return IPC_OK();
      40             :   }
      41           0 :   if (aEvent.type() == GamepadChangeEvent::TGamepadButtonInformation) {
      42           0 :     const GamepadButtonInformation& a = aEvent.get_GamepadButtonInformation();
      43           0 :     service->NewButtonEvent(a.index(), a.button(), a.pressed(), a.touched(),
      44           0 :                             a.value());
      45           0 :     return IPC_OK();
      46             :   }
      47           0 :   if (aEvent.type() == GamepadChangeEvent::TGamepadAxisInformation) {
      48           0 :     const GamepadAxisInformation& a = aEvent.get_GamepadAxisInformation();
      49           0 :     service->NewAxisMoveEvent(a.index(), a.axis(), a.value());
      50           0 :     return IPC_OK();
      51             :   }
      52           0 :   if (aEvent.type() == GamepadChangeEvent::TGamepadPoseInformation) {
      53           0 :     const GamepadPoseInformation& a = aEvent.get_GamepadPoseInformation();
      54           0 :     service->NewPoseEvent(a.index(), a.pose_state());
      55           0 :     return IPC_OK();
      56             :   }
      57             : 
      58           0 :   NS_WARNING("Unknown event type.");
      59           0 :   return IPC_FAIL_NO_REASON(this);
      60             : }
      61             : 
      62             : mozilla::ipc::IPCResult
      63           0 : GamepadTestChannelParent::RecvShutdownChannel()
      64             : {
      65           0 :   mShuttingdown = true;
      66           0 :   Unused << Send__delete__(this);
      67           0 :   return IPC_OK();
      68             : }
      69             : 
      70             : } // namespace dom
      71             : } // namespace mozilla

Generated by: LCOV version 1.13