Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e8d554f authored by David Duarte's avatar David Duarte
Browse files

Inline AlarmTestHarness in its only user

Test: mmm packages/modules/Bluetooth
Bug: 295430884
Change-Id: I0be369c4ff8dc34834ba9cd77072e5a5bdd4ebd0
parent e4e61fa2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ if (use.test) {
  executable("net_test_hci") {
    sources = [
      "//bt/system/osi/test/AllocationTestHarness.cc",
      "//bt/system/osi/test/AlarmTestHarness.cc",
      "test/packet_fragmenter_test.cc",
    ]

+0 −13
Original line number Diff line number Diff line
@@ -32,18 +32,6 @@ cc_test_library {
    },
}

cc_test_library {
    name: "libosi-AlarmTestHarness",
    defaults: ["fluoride_osi_defaults"],
    srcs: [
        "test/AlarmTestHarness.cc",
    ],
    host_supported: true,
    shared: {
        enabled: false,
    },
}

filegroup {
    name: "OsiCompatSources",
    srcs: [
@@ -126,7 +114,6 @@ cc_test {
    ],
    host_supported: true,
    srcs: [
        "test/AlarmTestHarness.cc",
        "test/AllocationTestHarness.cc",
        "test/alarm_test.cc",
        "test/allocation_tracker_test.cc",
+0 −1
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ static_library("osi") {
if (use.test) {
  executable("net_test_osi") {
    sources = [
      "test/AlarmTestHarness.cc",
      "test/AllocationTestHarness.cc",
      "test/alarm_test.cc",
      "test/allocation_tracker_test.cc",
+0 −57
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright 2014 Google, Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#include "AlarmTestHarness.h"

#include <hardware/bluetooth.h>

#include "osi/include/alarm.h"
#include "osi/include/wakelock.h"

static bool is_wake_lock_acquired = false;

static int acquire_wake_lock_cb(const char* lock_name) {
  is_wake_lock_acquired = true;
  return BT_STATUS_SUCCESS;
}

static int release_wake_lock_cb(const char* lock_name) {
  is_wake_lock_acquired = false;
  return BT_STATUS_SUCCESS;
}

static bt_os_callouts_t bt_wakelock_callouts = {
    sizeof(bt_os_callouts_t), NULL, acquire_wake_lock_cb, release_wake_lock_cb};

void AlarmTestHarness::SetUp() {
  AllocationTestHarness::SetUp();

  TIMER_INTERVAL_FOR_WAKELOCK_IN_MS = 500;

  wakelock_set_os_callouts(&bt_wakelock_callouts);
}

void AlarmTestHarness::TearDown() {
  alarm_cleanup();
  wakelock_cleanup();
  wakelock_set_os_callouts(NULL);

  AllocationTestHarness::TearDown();
}

bool AlarmTestHarness::WakeLockHeld() { return is_wake_lock_acquired; }
+0 −33
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright 2014 Google, Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#pragma once

#include "AllocationTestHarness.h"

extern int64_t TIMER_INTERVAL_FOR_WAKELOCK_IN_MS;

class AlarmTestHarness : public AllocationTestHarness {
 protected:
  virtual void SetUp();
  virtual void TearDown();

 public:
  // Returns true if a wake lock is held.
  bool WakeLockHeld();
};
Loading