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

Commit c3c51382 authored by Ajay Panicker's avatar Ajay Panicker Committed by Andre Eisenbach
Browse files

net_test_bluetooth: adapter test refactor

Properly integrating net_test_bluetooth to utilize GUnit correctly.
Contains all the adapter tests and base class that all the other tests
utilize. Also removed all the old test code.

Bug: 25793348
Change-Id: Ie05d54e9d21f01e2d717bb79d187d7f0ff8a83f1
parent 3615bc46
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -79,6 +79,17 @@ void AdapterPropertiesCallback(bt_status_t status,
      AdapterPropertiesCallback(status, num_properties, properties));
}

void DiscoveryStateChangedCallback(bt_discovery_state_t state) {
  lock_guard<mutex> lock(g_instance_lock);
  if (!g_bluetooth_interface) {
    LOG(WARNING) << "Callback recieved after global instance was destroyed";
    return;
  }

  VLOG(1) << "Discovery state changed - state: " << BtDiscoveryStateText(state);
  FOR_EACH_BLUETOOTH_OBSERVER(DiscoveryStateChangedCallback(state));
}

void ThreadEventCallback(bt_cb_thread_evt evt) {
  VLOG(1) << "ThreadEventCallback" << BtEventText(evt);

@@ -121,7 +132,7 @@ bt_callbacks_t bt_callbacks = {
  AdapterPropertiesCallback,
  nullptr, /* remote_device_properties_cb */
  nullptr, /* device_found_cb */
  nullptr, /* discovery_state_changed_cb */
  DiscoveryStateChangedCallback,
  nullptr, /* pin_request_cb  */
  nullptr, /* ssp_request_cb  */
  nullptr, /* bond_state_changed_cb */
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ class BluetoothInterface {
    virtual void AdapterPropertiesCallback(bt_status_t status,
                                           int num_properties,
                                           bt_property_t* properties) = 0;
    virtual void DiscoveryStateChangedCallback(bt_discovery_state_t state) = 0;

    // TODO(armansito): Complete the list of callbacks.
  };
+9 −0
Original line number Diff line number Diff line
@@ -63,6 +63,15 @@ const char *BtStateText(const bt_state_t state) {
  }
}

const char *BtDiscoveryStateText(const bt_discovery_state_t state) {
  switch (state) {
    CASE_RETURN_TEXT(BT_DISCOVERY_STOPPED);
    CASE_RETURN_TEXT(BT_DISCOVERY_STARTED);
    default:
      return "unknown discovery state code";
  }
}

const char *BtScanModeText(const bt_scan_mode_t mode) {
  switch (mode) {
    CASE_RETURN_TEXT(BT_SCAN_MODE_NONE);
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ const char *BtTransportText(const btgatt_transport_t t);

const char *BtStateText(const bt_state_t state);

const char *BtDiscoveryStateText(const bt_discovery_state_t);

const char *BtScanModeText(const bt_scan_mode_t mode);

const char *BtStatusText(const bt_status_t status);
+17 −14
Original line number Diff line number Diff line
@@ -21,33 +21,36 @@ include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := net_test_bluetooth

# These tests use the bluetoothtbd HAL wrappers in order to easily interact
# with the interface using C++
bluetoothHalSrc := \
  ../../service/hal/bluetooth_interface.cpp \
  ../../service/logging_helpers.cpp

LOCAL_C_INCLUDES += \
    $(LOCAL_PATH)/../../

LOCAL_SRC_FILES := \
    cases/adapter.c \
    cases/cases.c \
    cases/gatt.c \
    cases/pan.c \
    cases/rfcomm.c \
    support/adapter.c \
    support/callbacks.c \
    support/gatt.c \
    support/hal.c \
    support/pan.c \
    support/rfcomm.c \
    main.cpp
    adapter_unittest.cpp \
    bluetooth_test.cpp \
    $(bluetoothHalSrc)

LOCAL_SHARED_LIBRARIES += \
    liblog \
    libhardware \
    libhardware_legacy \
    libcutils
    libcutils \
    libchrome

LOCAL_STATIC_LIBRARIES += \
  libbtcore \
  libosi

LOCAL_CFLAGS += -Wall -Wno-unused-parameter -Wno-missing-field-initializers -Werror
LOCAL_CFLAGS += \
  -std=c++11 \
  -Wall \
  -Werror \
  -Wno-unused-parameter \
  -Wno-missing-field-initializers

include $(BUILD_NATIVE_TEST)
Loading