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

Commit e6f94965 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes Ib9cfa169,I3b85d2a6

* changes:
  Add test target TestCommonMockFunctions
  legacy: Add mock_common_os_utils
parents f1dcaa58 e6cafc92
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -168,7 +168,6 @@ hci_t mock_hci = {
    .transmit_downward = transmit_downward,
};

bool is_bluetooth_uid() { return false; }
const tBTA_AG_RES_DATA tBTA_AG_RES_DATA::kEmpty = {};

namespace bluetooth {
+7 −0
Original line number Diff line number Diff line
@@ -347,6 +347,13 @@ filegroup {
  ],
}

filegroup {
  name: "TestCommonMockFunctions",
  srcs: [
      "common/mock_functions.cc",
  ],
}

filegroup {
  name: "TestCommonMainHandler",
  srcs: [
+0 −5
Original line number Diff line number Diff line
@@ -19,11 +19,6 @@
#include "osi/include/log.h"
#include "test/common/mock_functions.h"

// tLEGACY_TRACE_LEVEL
// uint8_t btu_trace_level = 6;
uint8_t appl_trace_level = 6;
uint8_t btif_trace_level = 6;

std::map<std::string, int> mock_function_count_map;

void dump_mock_function_count_map() {
+64 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 The Android Open Source Project
 *
 * 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.
 */

/*
 * Generated mock file from original source file
 *   Functions generated:1
 *
 *  mockcify.pl ver 0.3.0
 */

#include <cstdint>
#include <functional>
#include <map>
#include <string>

extern std::map<std::string, int> mock_function_count_map;

// Mock include file to share data between tests and mock
#include "test/mock/mock_common_os_utils.h"

// Mocked internal structures, if any

namespace test {
namespace mock {
namespace common_os_utils {

// Function state capture and return values, if needed
struct is_bluetooth_uid is_bluetooth_uid;

}  // namespace common_os_utils
}  // namespace mock
}  // namespace test

// Mocked function return values, if any
namespace test {
namespace mock {
namespace common_os_utils {

bool is_bluetooth_uid::return_value = false;

}  // namespace common_os_utils
}  // namespace mock
}  // namespace test

// Mocked functions, if any
bool is_bluetooth_uid() {
  mock_function_count_map[__func__]++;
  return test::mock::common_os_utils::is_bluetooth_uid();
}
// Mocked functions complete
// END mockcify generation
+63 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 The Android Open Source Project
 *
 * 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

/*
 * Generated mock file from original source file
 *   Functions generated:1
 *
 *  mockcify.pl ver 0.3.0
 */

#include <cstdint>
#include <functional>
#include <map>
#include <string>

extern std::map<std::string, int> mock_function_count_map;

// Original included files, if any
// NOTE: Since this is a mock file with mock definitions some number of
//       include files may not be required.  The include-what-you-use
//       still applies, but crafting proper inclusion is out of scope
//       for this effort.  This compilation unit may compile as-is, or
//       may need attention to prune from (or add to ) the inclusion set.
#include <private/android_filesystem_config.h>
#include <unistd.h>

// Mocked compile conditionals, if any

namespace test {
namespace mock {
namespace common_os_utils {

// Shared state between mocked functions and tests
// Name: is_bluetooth_uid
// Params:
// Return: bool
struct is_bluetooth_uid {
  static bool return_value;
  std::function<bool()> body{[]() { return return_value; }};
  bool operator()() { return body(); };
};
extern struct is_bluetooth_uid is_bluetooth_uid;

}  // namespace common_os_utils
}  // namespace mock
}  // namespace test

// END mockcify generation
 No newline at end of file