mirror of
https://github.com/google/pebble.git
synced 2025-06-13 21:23:12 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
69
tests/fakes/fake_session_send_buffer.c
Normal file
69
tests/fakes/fake_session_send_buffer.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* 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 "fake_session_send_buffer.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static SendBuffer *s_stub_send_buffer = (SendBuffer *) ~0;
|
||||
|
||||
SendBuffer * comm_session_send_buffer_begin_write(CommSession *session, uint16_t endpoint_id,
|
||||
size_t required_free_length,
|
||||
uint32_t timeout_ms) {
|
||||
if (!session) {
|
||||
return NULL;
|
||||
}
|
||||
return s_stub_send_buffer;
|
||||
}
|
||||
|
||||
bool comm_session_send_buffer_write(SendBuffer *send_buffer, const uint8_t *data, size_t length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void comm_session_send_buffer_end_write(SendBuffer *send_buffer) {
|
||||
}
|
||||
|
||||
static int s_send_buffer_create_count;
|
||||
static bool s_send_buffer_create_simulate_oom;
|
||||
|
||||
SendBuffer * comm_session_send_buffer_create(bool is_system) {
|
||||
++s_send_buffer_create_count;
|
||||
if (s_send_buffer_create_simulate_oom) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (SendBuffer *) ~0;
|
||||
}
|
||||
}
|
||||
|
||||
static int s_send_buffer_destroy_count;
|
||||
|
||||
void comm_session_send_buffer_destroy(SendBuffer *sb) {
|
||||
++s_send_buffer_destroy_count;
|
||||
}
|
||||
|
||||
void fake_session_send_buffer_init(void) {
|
||||
s_send_buffer_create_count = 0;
|
||||
s_send_buffer_destroy_count = 0;
|
||||
s_send_buffer_create_simulate_oom = false;
|
||||
}
|
||||
|
||||
void fake_session_send_buffer_set_simulate_oom(bool enabled) {
|
||||
s_send_buffer_create_simulate_oom = enabled;
|
||||
}
|
||||
|
||||
SendBuffer *fake_session_send_buffer_get_buffer(void) {
|
||||
return s_stub_send_buffer;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue