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

Commit f006ca5a authored by Zach Johnson's avatar Zach Johnson Committed by Gerrit Code Review
Browse files

Merge changes I567f20fa,I67d1ed14

* changes:
  Format gd/os with new clang-format
  Format gd/common with new clang-format
parents 764d3b76 1e2a6a86
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -25,16 +25,13 @@ namespace bluetooth {
namespace common {

template <typename TENQUEUE, typename TDEQUEUE>
class BidiQueueEnd
    : public ::bluetooth::os::IQueueEnqueue<TENQUEUE>,
      public ::bluetooth::os::IQueueDequeue<TDEQUEUE> {
class BidiQueueEnd : public ::bluetooth::os::IQueueEnqueue<TENQUEUE>, public ::bluetooth::os::IQueueDequeue<TDEQUEUE> {
 public:
  using EnqueueCallback = Callback<std::unique_ptr<TENQUEUE>()>;
  using DequeueCallback = Callback<void()>;

  BidiQueueEnd(::bluetooth::os::IQueueEnqueue<TENQUEUE>* tx, ::bluetooth::os::IQueueDequeue<TDEQUEUE>* rx)
      : tx_(tx), rx_(rx) {
  }
      : tx_(tx), rx_(rx) {}

  void RegisterEnqueue(::bluetooth::os::Handler* handler, EnqueueCallback callback) override {
    tx_->RegisterEnqueue(handler, callback);
@@ -68,8 +65,7 @@ class BidiQueue {
      : up_queue_(capacity),
        down_queue_(capacity),
        up_end_(&down_queue_, &up_queue_),
        down_end_(&up_queue_, &down_queue_) {
  }
        down_end_(&up_queue_, &down_queue_) {}

  BidiQueueEnd<TDOWN, TUP>* GetUpEnd() {
    return &up_end_;
+21 −14
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@
#include "os/handler.h"
#include "os/thread.h"

using ::bluetooth::os::Thread;
using ::bluetooth::os::Handler;
using ::bluetooth::os::Thread;

namespace bluetooth {
namespace common {
@@ -52,17 +52,14 @@ class BidiQueueTest : public ::testing::Test {
  Handler* down_handler_;
};

class A {
};
class A {};

class B {
};
class B {};

template <typename TA, typename TB>
class TestBidiQueueEnd {
 public:
  explicit TestBidiQueueEnd(BidiQueueEnd<TA, TB>* end, Handler* handler)
      : handler_(handler), end_(end) {}
  explicit TestBidiQueueEnd(BidiQueueEnd<TA, TB>* end, Handler* handler) : handler_(handler), end_(end) {}

  ~TestBidiQueueEnd() {
    handler_->Clear();
@@ -70,7 +67,10 @@ class TestBidiQueueEnd {

  std::promise<void>* Send(TA* value) {
    std::promise<void>* promise = new std::promise<void>();
    handler_->Post(BindOnce(&TestBidiQueueEnd<TA, TB>::handle_send, common::Unretained(this), common::Unretained(value),
    handler_->Post(BindOnce(
        &TestBidiQueueEnd<TA, TB>::handle_send,
        common::Unretained(this),
        common::Unretained(value),
        common::Unretained(promise)));
    return promise;
  }
@@ -84,8 +84,13 @@ class TestBidiQueueEnd {
  }

  void handle_send(TA* value, std::promise<void>* promise) {
    end_->RegisterEnqueue(handler_, Bind(&TestBidiQueueEnd<TA, TB>::handle_register_enqueue, common::Unretained(this),
                                         common::Unretained(value), common::Unretained(promise)));
    end_->RegisterEnqueue(
        handler_,
        Bind(
            &TestBidiQueueEnd<TA, TB>::handle_register_enqueue,
            common::Unretained(this),
            common::Unretained(value),
            common::Unretained(promise)));
  }

  std::unique_ptr<TA> handle_register_enqueue(TA* value, std::promise<void>* promise) {
@@ -95,8 +100,10 @@ class TestBidiQueueEnd {
  }

  void handle_receive(std::promise<TB*>* promise) {
    end_->RegisterDequeue(handler_, Bind(&TestBidiQueueEnd<TA, TB>::handle_register_dequeue, common::Unretained(this),
                                         common::Unretained(promise)));
    end_->RegisterDequeue(
        handler_,
        Bind(
            &TestBidiQueueEnd<TA, TB>::handle_register_dequeue, common::Unretained(this), common::Unretained(promise)));
  }

  void handle_register_dequeue(std::promise<TB*>* promise) {
@@ -132,5 +139,5 @@ TEST_F(BidiQueueTest, simple_test) {
}

}  // namespace
}  // namespace os
}  // namespace common
}  // namespace bluetooth
+2 −2
Original line number Diff line number Diff line
@@ -16,10 +16,10 @@

#include "common/blocking_queue.h"

#include <thread>

#include <gtest/gtest.h>

#include <thread>

namespace bluetooth {
namespace common {
namespace {
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#pragma once

#include <utility>

#include "base/callback_list.h"
#include "os/handler.h"

+4 −2
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
 ******************************************************************************/

#include "common/link_key.h"

#include <gtest/gtest.h>

#include "os/log.h"

using bluetooth::common::LinkKey;
@@ -25,8 +27,8 @@ using bluetooth::common::LinkKey;
static const char* test_link_key = "4c68384139f574d836bcf34e9dfb01bf\0";

TEST(LinkKeyUnittest, test_constructor_array) {
  uint8_t data[LinkKey::kLength] = {0x4c, 0x87, 0x49, 0xe1, 0x2e, 0x55, 0x0f, 0x7f,
                                    0x60, 0x8b, 0x4f, 0x96, 0xd7, 0xc5, 0xbc, 0x2a};
  uint8_t data[LinkKey::kLength] = {
      0x4c, 0x87, 0x49, 0xe1, 0x2e, 0x55, 0x0f, 0x7f, 0x60, 0x8b, 0x4f, 0x96, 0xd7, 0xc5, 0xbc, 0x2a};

  LinkKey link_key(data);

Loading