chromium/device/gamepad/hid_haptic_gamepad_unittest.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "device/gamepad/hid_haptic_gamepad.h"

#include <memory>

#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/task_environment.h"
#include "device/gamepad/hid_writer.h"
#include "device/gamepad/public/mojom/gamepad.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace device {

namespace {

// Describes a hypothetical HID haptic gamepad with two 16-bit vibration
// magnitude fields.
constexpr uint8_t kReportId =;
constexpr size_t kReportLength =;
constexpr HidHapticGamepad::HapticReportData kHapticReportData =;

// The expected "stop vibration" report bytes (zero vibration).
constexpr uint8_t kStopVibrationData[] =;
// The expected "start vibration" report bytes for an effect with 100% intensity
// on the "strong" vibration channel and 50% intensity on the "weak" vibration
// channel.
constexpr uint8_t kStartVibrationData[] =;

// Use 1 ms for all non-zero effect durations. There is no reason to test longer
// delays as they will be skipped anyway.
constexpr double kDurationMillis =;
constexpr double kNonZeroStartDelayMillis =;
// Setting |start_delay| to zero can cause additional reports to be sent.
constexpr double kZeroStartDelayMillis =;
// Vibration magnitudes for the strong and weak channels of a typical
// dual-rumble vibration effect. kStartVibrationData describes a report with
// these magnitudes.
constexpr double kStrongMagnitude =;  // 100% intensity
constexpr double kWeakMagnitude =;    // 50% intensity
// Zero vibration magnitude. kStopVibrationData describes a report with zero
// vibration on both channels.
constexpr double kZeroMagnitude =;

constexpr base::TimeDelta kPendingTaskDuration =;

class FakeHidWriter : public HidWriter {};

// Main test fixture
class HidHapticGamepadTest : public testing::Test {};

TEST_F(HidHapticGamepadTest, PlayEffectTest) {}

TEST_F(HidHapticGamepadTest, ResetVibrationTest) {}

TEST_F(HidHapticGamepadTest, ZeroVibrationTest) {}

TEST_F(HidHapticGamepadTest, StartDelayTest) {}

TEST_F(HidHapticGamepadTest, ZeroStartDelayPreemptionTest) {}

TEST_F(HidHapticGamepadTest, NonZeroStartDelayPreemptionTest) {}

TEST_F(HidHapticGamepadTest, ResetVibrationPreemptionTest) {}

}  // namespace

}  // namespace device