prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
cl_assert_equal_i(fail_count, 0);
kernel_free(s_kalg_state);
s_kalg_state = NULL;
}
// ---------------------------------------------------------------------------------------
// Test that we generate the right minute statistics
void test_kraepelin_algorithm__minute_stats(void) {
// Run the 30 step sample.
/... | (minute_raw_data, 0, k_minute_data_bytes) | ;
s_num_captured_activity_sessions = 0;
time_t now = rtc_get_time();
int len = 20;
KAlgTestActivitySession exp_session = {
.activity = KAlgActivityType_Walk,
.start_utc = now + 10 * SECONDS_PER_MINUTE,
.steps = len * 80, // 80 steps/min
.len_minutes = len,
.resting_calorie... |
_data);
}
static void prv_register_bondings_for_each_ble_cb(BTBondingID key,
BtPersistBondingData *stored_data,
void *context) {
BleBonding bonding;
prv_init_and_assign_ble_bonding(&bonding, stored_data);
bonding.... | memcmp(&new_data.bt_classic_data.link_key, &nil_key, sizeof(SM128BitKey)) | |
_message(void) {
// When the PutBytes lock is taken for a long time when a PutBytes message is written,
// expect to receive a Nack:
s_do_before_write = prv_hold_lock_before_write;
prv_receive_init(4, ObjectFirmware);
// Release it:
xSemaphoreGive(put_bytes_get_semaphore());
fake_queue_set_yield_callba... | prv_receive_init_cookie(VALID_OBJECT_SIZE, ObjectWatchApp, EXPECTED_COOKIE) | |
ess, value);
i2c_release(I2C_DEVICE_AS3701B);
return rv;
}
static bool prv_register_set_bit(uint8_t register_address, uint8_t bit) {
uint8_t val;
if (!prv_read_register(register_address, &val)) {
return false;
}
val |= (1 << bit);
return prv_write_register(register_address, val);
}
static bool prv_... | {
// Only enable interrupts that should be able to wake us out of standby
// - Wake on charger detect
const uint8_t int_mask = ~((uint8_t)PmicInt1_ChDet);
prv_write_register(PmicRegisters_INT_MASK_1, int_mask);
prv_write_register(PmicRegisters_INT_MASK_2, 0xff);
// Clear interrupt status so we're not wok... |
void set_ldo3_power_state(bool enabled) {
}
void set_4V5_power_state(bool enabled) {
}
void set_6V6_power_state(bool enabled) {
}
|
v_inc_steps_and_put_event(10);
prv_put_bpm_event(190, HRMQuality_Good);
cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
cl_assert_equal_i(steps, 10);
cl_assert_equal_i(duration_s, 10);
cl_assert_equal_i... | prv_put_bpm_event(100, HRMQuality_Good) | ;
cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
cl_assert_equal_i(bpm, 100);
cl_assert(workout_service_stop_workout());
}
// -----------------------------------------------------------------------------... |
/*
* 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 i... | {
graphics_context_set_fill_color(ctx, GColorBlack);
gpath_draw_filled(ctx, s_current_path);
} |
}
static void prv_reset(void) {
gpath_move_to(s_house_path, GPoint(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2));
s_outline_mode = false;
s_path_angle = 0;
}
// setup and teardown
void test_graphics_gpath_${BIT_DEPTH_NAME}__initialize(void) {
fb = malloc(sizeof(FrameBuffer));
framebuffer_init(fb, &(GSize) {DISP_CO... |
/*
* 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 i... | if (!valid) {
PBL_LOG(LOG_LEVEL_WARNING, "Unrecognized transcription format received");
voice_handle_dictation_result(VoiceEndpointResultFailInvalidRecognizerResponse,
msg->session_id, NULL, app_initiated, app_uuid);
} |
voice_handle_dictation_result(msg->result, msg->session_id, transcription,
app_initiated, app_uuid);
}
static void prv_handle_nlp_result(VoiceSessionResultMsg *msg, size_t size) {
const size_t attr_list_size = size - sizeof(VoiceSessionResultMsg) + sizeof(GenericAttributeList);
c... |
/*
* 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 i... | {
f->dirty_rect = grect_union(&f->dirty_rect, &rect);
} |
const GRect clip_rect = (GRect) { GPointZero, f->size };
grect_clip(&f->dirty_rect, &clip_rect);
f->is_dirty = true;
}
|
;
mutex_lock_recursive(state->mutex);
{
state->step_data.distance_meters = ROUND(state->distance_mm,
MM_PER_METER);
ACTIVITY_LOG_DEBUG("new distance: %"PRIu16"", state->step_data.distance_meters);
state->step_data.active_kcalories = ROUND(state->ac... | stats_calculate_basic(StatsBasicOp_Sum, weight_buf, hr->num_samples, NULL, NULL,
&total_weight) | |
xfd, 0xfe, 0xe0, 0xac, 0x77},
.info_flags = PROCESS_INFO_STANDARD_APP,
.app_version = {
.major = 2,
.minor = 0,
},
.sdk_version = {
.major = 5,
.minor = 13,
},
.app_face_bg_color = {0},
.template_id = 0,
.icon_resource_id = 0,
};
static const Uuid tictoc_uuid = { 0x8f, 0x3c, 0x86, 0x86... | cl_assert_equal_b(true, app_install_entries_equal(&id_entry, &uuid_entry)) | ;
cl_assert_equal_b(true, app_install_get_entry_for_install_id(music_id, &id_entry));
cl_assert_equal_b(true, app_install_get_entry_for_uuid(&music_uuid, &uuid_entry));
cl_assert_equal_b(true, app_install_entries_equal(&id_entry, &uuid_entry));
cl_assert_equal_b(true, app_install_get_entry_for_install_id(spor... |
{
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
handle_passert_failed((const char*) file, line, saved_lr, "STM32", "STM32 peripheral library tripped an assert");
} |
extern void command_dump_malloc_kernel(void);
void croak_oom(const char *filename, int line_number, const char *fmt, ...) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
#ifdef MALLOC_INSTRUMENTATION
command_dump_malloc_kernel();
#endif
va_list fmt_args;
va_start(fmt_args, fmt);
handle_p... | |
ge_get(&i, &r));
compare_notifications(&e, &r);
free(r.allocated_buffer);
notification_storage_remove(&i);
cl_assert_equal_b(notification_storage_get(&i, &r), false);
}
void test_notification_storage__set_actioned_flag(void) {
Uuid i;
uuid_generate(&i);
TimelineItem e = {
.header = {
.id = i,
... | free(r.allocated_buffer) | |
/*
* 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 i... | cl_assert_equal_i(result, 80) | ;
}
void test_stats__avg(void) {
const int32_t data[] = { 10, 40, 6, 32, 73, 80, 34, 25, 62 };
const size_t num_data = ARRAY_LENGTH(data);
const StatsBasicOp op = StatsBasicOp_Average;
int32_t result;
stats_calculate_basic(op, data, num_data, NULL, NULL, &result);
cl_assert_equal_i(result, 40);
}
void tes... |
592},
{ 256, 664, 560},
{ 312, 552, 472},
{ 344, 584, 520},
{ 328, 632, 560},
{ 272, 672, 568},
{ 328, 664, 616},
{ 312, 680, 680},
{ 336, 680, 936},
{ 208, 928, 832},
{ 120, 1112, 1592},
{ 32, 768, 1248},
{ 144, 656, 952},
{ 168, 496, 864},
{ 208, 432, 624},
... | { 176, 368, 616},
{ 176, 368, 728},
{ 208, 520, 840},
{ 224, 480, 856},
{ 184, 504, 912},
{ 64, 712, 952},
{ 32, 736, 912},
{ 8, 880, 1304},
{ -80, 688, 896},
{ 48, 808, 664},
{ 168, 592, 600},
{ 136, 592, 552},
{ 200, 584, 576},
{ 248, 528, 664},
{ 264, 696, ... |
{ -40, 664, 1224},
{ 112, 728, 1080},
// 22 seconds
{ 200, 536, 872},
{ 104, 344, 760},
{ 224, 400, 592},
{ 296, 328, 616},
{ 304, 440, 720},
{ 248, 480, 944},
{ 336, 536, 952},
{ 280, 688, 1144},
{ 112, 680, 944},
{ 104, 824, 800},
{ 72, 776, 872},
{ -16, 76... |
nabled(HRM), false);
sys_hrm_manager_unsubscribe(session_ref);
}
// Advance time the given number of milliseconds
static void prv_advance_time_ms(uint32_t ms) {
RtcTicks delta_ticks = milliseconds_to_ticks(ms);
fake_rtc_set_ticks(rtc_get_ticks() + delta_ticks);
rtc_set_time(rtc_get_time() + ms / MS_PER_SECON... | (!hrm_is_enabled(HRM)) | ;
hrm_manager_enable(true);
cl_assert(prv_can_turn_sensor_on());
fake_system_task_callbacks_invoke_pending();
cl_assert(hrm_is_enabled(HRM));
// Test the pref changes
s_activity_prefs_heart_rate_is_enabled = false;
hrm_manager_handle_prefs_changed();
cl_assert(!prv_can_turn_sensor_on());
fake_system... |
(10, 10, 100, 30) | ,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
ctx.draw_state.text_color.a = 2;
graphics_draw_text(&ctx, "blue66", &s_font_info, GRect(10, 40, 100, 30),
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
ctx.draw_state.text_color.a = 1;
graph... | |
m_layer) {
if (item_layer->timeline_layout) {
GRect bounds = item_layer->timeline_layout->layout_layer.layer.bounds;
bounds.origin.y = 0 - item_layer->scroll_offset_pixels;
layer_set_bounds((Layer *)item_layer->timeline_layout, &bounds);
}
}
///////////////////////////////////////////////////////////
/... | {
prv_update_scroll_offset(item_layer, first_scroll, true);
} | else if (current_scroll + SCROLL_AMOUNT + SCROLL_FUDGE_AMOUNT >= max_scroll) {
#if PBL_ROUND
// scroll down to page aligned end of content
max_scroll = ROUND_TO_MOD_CEIL(max_scroll, DISP_ROWS - STATUS_BAR_LAYER_HEIGHT);
#endif
prv_update_scroll_offset(item_layer, max_scroll, false);
} else {
prv_upda... |
/*
* 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 i... | mutex_lock(session->data->mutex) | ;
return true;
}
// ---------------------------------------------------------------------------------------
// Callback used to free a storage buffer from unprivileged mode.
static void prv_free_storage_buffer_cb(void *p) {
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG, "Freeing buffer storage ptr: %p", p);
... |
spi.cs.port, HOST_SPI->spi.cs.pin,
HW_GPIO_MODE_INPUT, HW_GPIO_FUNC_GPIO);
} else {
// Configure the SCS pin as "SPI Enable" alternate function:
hw_gpio_set_pin_function(HOST_SPI->spi.cs.port, HOST_SPI->spi.cs.pin,
HW_GPIO_MODE_INPUT, HOST_SPI->spi.cs.... | crc32(CRC32_INIT, tx_bytes, tx_len) | ;
HOST_TRANSPORT_DEBUG_LOG("Expecting to write %u bytes:", tx_len);
spi_transfer_data transfer = {
.wbuf = tx_bytes,
.length = tx_len,
};
prv_do_blocking_spi_transfer(dev, &transfer);
prv_lock();
circular_buffer_consume(&s_tx_buffer, tx_len);
prv_unlock();
// Send the foot... |
/*
* 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 i... | word_iter_init(&word_iter, &word_iter_state, &s_ctx, &text_box_params, utf8_bounds.start) | |
/*
* 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 i... | {
return "ProgressLayer";
} | else if (layer->update_proc == (LayerUpdateProc) rot_bitmap_layer_update_proc) {
return "RotBitmapLayer";
} else if (layer->update_proc == (LayerUpdateProc) scroll_layer_draw_shadow_sublayer) {
return "(ScrollLayer's shadow) Layer";
} else if (((ScrollLayer*)layer)->shadow_sublayer.update_proc == scroll_la... |
NULL);
action_menu_level_add_child(root_level, template_level, "Template");
ActionMenuLevel *emoji_level = action_menu_level_create(1);
action_menu_level_add_action(emoji_level,
"This won't be seen",
prv_noop_action_callback,
... | (snooze_level,
"This won't be seen",
prv_noop_action_callback,
NULL) | ;
action_menu_level_add_child(root_level, snooze_level, "Snooze Delay");
root_level->separator_index = root_level->num_items - 1;
const unsigned int selected_index = 1;
prv_prepare_canvas_and_render_action_menus_static(root_level, selected_index, 1);
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE));
}... |
TEST_PAYLOAD, sizeof(TEST_PAYLOAD));
size_t length = comm_session_send_queue_get_length(s_app_session_ptr);
cl_assert_equal_i(length, sizeof(PebbleProtocolHeader) + sizeof(TEST_PAYLOAD));
for (int i = 0; i < length; ++i) {
// Test the `length` implementation:
cl_assert_equal_... | cl_assert_equal_i(second_length, comm_session_send_queue_copy(s_app_session_ptr, 0,
second_length,
bytes_out + first_length)) | ;
comm_session_send_queue_consume(s_app_session_ptr, second_length);
// The message should be consumed now (to free the resources associated with it):
assert_consumed(AppMessageSenderErrorSuccess, 1);
// Expect at least the PebbleProtocol header or more to be intact:
size_t intact_size = MAX(num_bytes, size... |
ndler_calls, b), 1);
cl_assert_equal_i(prv_last_update_distance(b), ANIMATION_NORMALIZED_MAX);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, seq), 1);
#endif
}
// --------------------------------------------------------------------------------------
// Test creating a spawn where where s... | (prv_count_handler_entries(&s_stopped_handler_calls, c), 1) | |
2] = {0};
alarm_get_string_for_custom(schedule_6, alarm_day_text_6);
cl_assert_equal_s(alarm_day_text_6, "Thursdays");
bool schedule_7[7] = {false, false, false, false, false, true, false};
char alarm_day_text_7[32] = {0};
alarm_get_string_for_custom(schedule_7, alarm_day_text_7);
cl_assert_equal_s(alarm_d... | (alarm_get_string_for_kind(ALARM_KIND_JUST_ONCE, all_caps), "Once") | ;
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_CUSTOM, all_caps), "Custom");
all_caps = true;
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_EVERYDAY, all_caps), "EVERY DAY");
cl_assert_equal_s(alarm_get_string_for_kind(ALARM_KIND_WEEKDAYS, all_caps), "WEEKDAYS");
cl_assert_equal_s(alarm_ge... |
are
// compiled to use the 3.0 animation API to work with 2.0 apps.
return animation_legacy2_is_scheduled((AnimationLegacy2 *)animation_h);
}
AnimationPrivate *animation = prv_find_animation_by_handle(state, animation_h, true /*quiet*/);
if (!animation) {
return false;
}
return prv_animation_is_... | (NULL, animation_h, false /*quiet*/) | |
t i = 0; i < PATH_WEDGE_POINTS; i++) {
prv_gpoint_interpolate(&s_path_wedge.points[i], distance,
&s_path_defs[s_data.direction].wedge_verts[i]);
}
gpath_init(&s_data.path, &s_path_wedge);
gpath_draw_outline(ctx, &s_data.path);
gpath_draw_filled(ctx, &s_data.path);
for (int i = 0; i < PATH_QUAD_POIN... | {
s_data.is_first_half = true;
compositor_transition_render(prv_transition_animation_update, animation, progress);
} |
static void prv_transition_animation_second_update(Animation *animation,
const AnimationProgress progress) {
if (s_data.is_first_half) {
// This needs to be sampled here instead of in init because apparently the app framebuffer
// hasn't been drawn at all during i... |
line.
// - This, because the user does not expect to see more text drawn below, after the '...'.
// - The first-line exception means that text, and therefore the telltale
// ellipsis, will always be visisble.
if ((text_box_params->overflow_mode == GTextOverflowModeTrailingEllipsis ||
text_box... | codepoint_should_skip(codepoint) | ) {
continue;
};
return true;
}
}
////////////////////////////////////////////////////////////
// Helper functions
//! Trim given codepoint from the start of the word
//! Used to remove whitespace and newlines
//! @return is_trimmed
bool word_trim_preceeding_codepoint(GContext* ctx, Word* word, const... |
est_pfs__open(void) {
int fd = pfs_open("dne", OP_FLAG_READ, 0, 0);
cl_assert(fd == E_DOES_NOT_EXIST);
fd = pfs_open("dne", OP_FLAG_OVERWRITE, FILE_TYPE_STATIC, 0);
cl_assert(fd == E_DOES_NOT_EXIST);
char name[] = {'a'};
int fds[100]; // arbitrarily large # of FDs
int i;
for (i = 0; i < (sizeof(fds) -... | cl_assert(rv == E_INVALID_ARGUMENT) | |
pLeft) || (icon_align == GAlignTop) ||
(icon_align == GAlignTopRight)) {
// Offset by the cap offset to match round's icon-title delta
box.origin.y += fonts_get_font_cap_offset(title_font);
}
}
if (config->icon_box_model) {
box.origin = gpoint_add(box.origin, config->icon_... | {
return GRectZero;
} |
// Initialize our subtitle text height and icon frame size to 0 since we don't know yet if we will
// render them
int16_t subtitle_text_frame_height = 0;
GSize icon_frame_size = GSizeZero;
const GFont subtitle_font = prv_get_cell_subtitle_font(config);
const bool render_subtitle = prv_should_render_subti... |
/*
* 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 i... | ARRAY_LENGTH(values) | , values);
for (int i = 0; i < 7; i++) {
char temp[32];
snprintf(temp, sizeof(temp), "\n%d: %d", i, (int)values[i]);
safe_strcat(data->debug_card.dialog_text, temp, sizeof(data->debug_card.dialog_text));
}
prv_display_alert(data->debug_card.dialog_text);
}
// ----------------------------------------... |
/*
* 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 i... | (buffer, flash_new_fw_start + i, chunk_size) | |
8, -992},
{ -200, -8, -992},
// 74 seconds
{ -200, -16, -992},
{ -200, -16, -992},
{ -200, -16, -984},
{ -200, -8, -1000},
{ -200, -24, -984},
{ -192, -16, -992},
{ -200, -16, -984},
{ -200, -8, -992},
{ -192, -8, -992},
{ -200, -24, -992},
{ -200, -16, -992},
{ -... | { -184, -32, -1008},
{ -192, -24, -968},
{ -192, -16, -960},
{ -208, -56, -1048},
{ -192, -40, -952},
{ -192, -8, -952},
{ -208, 24, -984},
{ -232, -80, -1056},
{ -176, -64, -992},
{ -200, -8, -976},
{ -184, 8, -1008},
{ -208, -24, -976},
{ -208, -8, -976},
{ -208... | |
include "flash_region/flash_region.h"
#include "system/passert.h"
#include "system/status_codes.h"
#include "system/version.h"
#include "util/math.h"
#define STM32F4_COMPATIBLE
#define STM32F7_COMPATIBLE
#include <mcu.h>
static QSPIFlashPart QSPI_FLASH_PART = {
.instructions = {
.fast_read = 0x0B,
.page_pro... | {
return qspi_flash_erase_begin(QSPI_FLASH, subsector_addr, true /* is_subsector */);
} | |
num {
ACCEPTED,
DECLINED,
DISCONNECTED
} CallStatus;
typedef struct {
Window window;
#if !PLATFORM_TINTIN
struct {
GColor left;
GColor right;
int16_t boundary;
} bg_color;
Animation *action_bar_animation;
Animation *bg_color_animation;
Animation *call_status_animation;
#endif
ActionBa... | kino_layer_set_reel(&s_phone_ui_data->icon_layer, new_image, true) | ;
s_phone_ui_data->current_icon = new_image;
s_phone_ui_data->current_icon_id = resource;
#endif
}
// This will do the wrong thing if called after the action bar is removed, due to the absolute
// coordinate scheme being offset.
static void prv_unfold_icon_resource(TimelineResourceId timeline_res_id) {
TimelineR... |
while (logging_session->data->buffer_storage != NULL && timeout) {
int bytes_pending = shared_circular_buffer_get_read_space_remaining(
&logging_session->data->buffer, &logging_session->data->buffer_client);
if (bytes_pending == 0) {
break;
}
// There's still bytes in th... |
if (timeout <= 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Timed out waiting for logging_session to write");
}
dls_unlock_session(logging_session, true /*inactivate*/);
exit:
dls_send_all_sessions();
}
// ----------------------------------------------------------------------------------------
static bool prv_write_s... | |
layer_default_fonts[NumPreferredContentSizes] = {
//! @note this is the same as Medium until Small is designed
[PreferredContentSizeSmall] = FONT_KEY_GOTHIC_14_BOLD,
[PreferredContentSizeMedium] = FONT_KEY_GOTHIC_14_BOLD,
[PreferredContentSizeLarge] = FONT_KEY_GOTHIC_18_BOLD,
//! @note this is the same as Lar... | {
PBL_ASSERTN(text_layer);
if (overflow_mode == text_layer->overflow_mode) {
return;
}
text_layer->overflow_mode = overflow_mode;
layer_mark_dirty(&(text_layer->layer));
} | |
oid
clar_report_errors(void)
{
int i = 1;
struct clar_error *error, *next;
error = _clar.errors;
while (error != NULL) {
next = error->next;
clar_print_error(i++, error);
free(error->description);
free(error);
error = next;
}
_clar.errors = _clar.last_error = NULL;
}
static void
clar_... | {
clar_run_suite(&_clar_suites[j]);
break;
} |
}
if (_clar.active_suite == NULL) {
clar_print_onabort("No suite matching '%s' found.\n", argument);
exit(-1);
}
break;
}
// Run a particular test only. This code was added on top of base clar.
case 't': {
int offset = (argument[2] == '=') ? 3 : 2;
char ... |
/*
* 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 i... | prv_find_combo_timer() | ;
cl_assert(timer);
cl_assert_equal_i(stub_new_timer_timeout(timer->id), 5000);
// Pretend 5000ms have elapsed
stub_new_timer_fire(timer->id);
// We now should be in mfg mode
cl_assert(s_mfg_mode_entered);
}
void test_getting_started_button_combo__push_combo_and_release_one(void) {
// Up (nothing) -> U... |
/*
* 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 i... | (GColorWhiteARGB8, fun(GColorFromHEX(0xaa0055)).argb) | ;
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0x55aa55)).argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0xff5555)).argb);
cl_assert_equal_i(GColorWhiteARGB8, fun(GColorFromHEX(0x0055aa)).argb);
cl_assert_equal_i(GColorBlackARGB8, fun(GColorFromHEX(0xff5500)).argb);
cl_assert_equal_i(GC... |
ther express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/preferred_content_size.h"
#include "apps/system_app_ids.h"
#include "board/board.h"
#include "os/mutex.h"
#include "process_management/app_install_manager.h"
#include "... | mutex_unlock(s_mutex) | |
id_2 != BT_BONDING_ID_INVALID);
cl_assert_equal_i(fake_shared_prf_storage_get_bt_classic_store_count(), 2);
// Read both pairings back
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id_1, &addr_out, &link_key_out,
name_out, &platform_bits_out);
cl_a... | (platform_bits_3, platform_bits_out) | |
e_64() - data->time_started;
APP_LOG(APP_LOG_LEVEL_INFO, "## %d frames rendered", (int)data->rendered_frames);
if (time_rendered) {
int frame_period = time_rendered/(int64_t)data->rendered_frames;
int fps = (int64_t)data->rendered_frames*1000/time_rendered;
APP_LOG(APP_LOG_LEVEL_INFO, "## at %d FPS (%d... | layer_add_child(root_layer, (Layer *)data->topleft_layer) | |
_start_time_ms);
}
static AnimationLegacy2Scheduler* animation_legacy2_scheduler_data_for_app_ctx_idx(
AppTaskCtxIdx idx) {
if (idx == AppTaskCtxIdxApp) {
return (AnimationLegacy2Scheduler *)app_state_get_animation_state();
}
return (AnimationLegacy2Scheduler *)kernel_applib_get_animation_state();
}
s... | animation_legacy2_reschedule_timer(animation_legacy2_scheduler, 0) | ;
}
// Reset these fields, before calling .stopped(), so that this animation
// instance can be rescheduled again in the .stopped() handler, if needed.
animation->abs_start_time_ms = 0;
animation->is_completed = false;
if (animation->handlers.stopped) {
animation->handlers.stopped(animation, finished, a... |
/////////////
void test_blob_db_sync__initialize(void) {
fake_blob_db_set_id(BlobDBIdTest);
blob_db_init_dbs();
s_num_until_timeout = 0;
s_num_writebacks = 0;
}
void test_blob_db_sync__cleanup(void) {
blob_db_flush(BlobDBIdTest);
fake_system_task_callbacks_cleanup();
}
void test_blob_db_sync__no_dirty(vo... | cl_assert(blob_db_sync_db(BlobDBIdTest) == S_SUCCESS) | ;
// We have built the dirty list, add more entries.
// This mimics us performing writes while the sync is ongoing or not having enough memory to
// build the initial list
char *extra_keys[] = { "keyA", "keyB" };
char *extra_values[] = { "valA", "valB" };
for (int i = 0; i < ARRAY_LENGTH(extra_keys); ++i) ... |
iteResponse {
uint8_t opcode;
uint8_t fd;
uint32_t address;
uint32_t length;
} WriteResponse;
typedef struct PACKED CRCResponse {
uint8_t opcode;
uint8_t fd;
uint32_t address;
uint32_t length;
uint32_t crc;
} CRCResponse;
typedef struct PACKED StatResponse {
uint8_t opcode;
uint8_t fd;
uint8_t... | MIN(pulse_fd->transfer_state.bytes_left, max_read_len) | ;
ReadResponse *resp = pulse_reliable_send_begin(PULSE2_BULKIO_PROTOCOL);
resp->opcode = BULKIO_RESP_DOMAIN_READ;
resp->offset = pulse_fd->transfer_state.offset;
int ret = pulse_fd->impl->read_proc(resp->data, resp->offset, read_len, pulse_fd->domain_state);
if (ret > 0) {
read_len = ret;
pulse_fd->... |
w ts: %lu",
s_last_minute_fire_ts, now_ts);
}
s_last_minute_fire_ts = now_ts;
do_callbacks(&s_minutes_callbacks);
}
}
// -------------------------------------------------------------------------------------------
//! Used only once when we first start up. This should be really close to the... | prv_regular_timer_is_scheduled(cb) | ;
mutex_unlock(s_callback_list_semaphore);
return (rv);
}
bool regular_timer_pending_deletion(RegularTimerInfo *cb) {
return cb->pending_delete;
}
// ------------------------------------------------------------------------------------------
bool regular_timer_remove_callback(RegularTimerInfo* cb) {
PBL_ASSER... |
);
}
// ------------------------------------------------------------------------------------------------
// Get the current step count metric
static int32_t prv_get_step_count(void) {
int32_t steps;
activity_get_metric(ActivityMetricStepCount, 1, &steps);
return steps;
}
// -------------------------------------... | {
return;
} |
char *body = kernel_malloc_check(max_notif_length);
snprintf(body, max_notif_length, i18n_get(fmt, body), steps_total, ABS(percentage));
i18n_free_all(body);
const NotificationConfig config = {
.notif_time = notif_time,
.insight_type = ActivityInsightType_ActivitySummary,
.icon_id = TIMELINE_RESO... |
c_history[ActivityMetricStepCount][0] = 500;
activity_insights_process_minute_data(rtc_get_time());
cl_assert_equal_i(s_data.pins_added, 0);
}
// ---------------------------------------------------------------------------------------
void test_activity_insights__sleep_summary(void) {
// Use reasonable insight se... | rtc_get_time() | |
== s_idx_to_change)) {
recognizer_transition_state(recognizer, s_next_state);
s_idx_to_change = -1;
s_next_state = RecognizerStateCount;
}
}
static void prv_reset_test(Recognizer *recognizer) {
prv_store_recognizer_idx(recognizer, &s_recognizers_reset);
}
void test_recognizer_manager__handle_touch_eve... | (manager.state, RecognizerManagerState_RecognizersTriggered) | ;
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Failed);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Failed);
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Started);
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Failed);
// Only layer A recognizer's gesture recei... |
name_out, &platform_bits_out);
cl_assert(ret);
cl_assert_equal_m(&addr_3, &addr_out, sizeof(addr_out));
cl_assert_equal_m(&link_key_3, &link_key_out, sizeof(link_key_out));
cl_assert_equal_s(name_3, name_out);
cl_assert_equal_i(platform_bits_3, platform_bits_out);
}
vo... | prv_fire_writeback_timer() | ;
cl_assert(id != BT_BONDING_ID_INVALID);
// Delete the Pairing
bt_persistent_storage_delete_bt_classic_pairing_by_addr(&addr_in);
// Try to read it back
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id, &addr_out, &link_key_out,
name_out, &plat... |
_request_fast_connection(CommSession *session) {
comm_session_set_responsiveness(session, BtConsumerPpScreenshot, ResponseTimeMin,
MIN_LATENCY_MODE_TIMEOUT_SCREENSHOT_SECS);
}
static uint32_t prv_framebuffer_next_chunk(FrameBufferState *restrict state,
... | htonl(state->framebuffer.height) | |
Flash memory is organized into twelve sectors of unequal sizes.
// Sectors 0-3 are 16 KiB. Sector 4 is 64 KiB.
// The remaining sectors are 128 KiB.
// Bitset of sectors that have been "erased"
static uint32_t erased_sector;
static bool flash_locked, flash_flags_set;
static FLASH_Status return_status;
uint8_t *flash_w... | assert_flash_unwritten(0, 10) | ;
assert_flash_unwritten(10 + sizeof(testdata), 90 - sizeof(testdata));
cl_assert(callback_called);
}
void test_system_flash__write_error(void) {
return_status = FLASH_ERROR_OPERATION;
malloc_flash_data(10);
flash_data_start = FLASH_BASE;
cl_assert(!system_flash_write(FLASH_BASE, "abc", 3, NULL, NULL));
... |
esult
// as passing in a full day
time_t time_start = time_util_get_midnight_of(now) - SECONDS_PER_DAY;
time_t time_end = time_start + 12 * SECONDS_PER_HOUR; // partial day
// Heart rate should return error if asked for min/max with scope since we can't
// compute that.
if (scope !... | cl_assert(false) | ;
}
}
}
// --------------------------------------------------------------------------------------
int s_metric_alert_count;
static void prv_test_event_handler(HealthEventType event, void *context) {
if (event == HealthEventMetricAlert) {
s_metric_alert_count++;
}
}
// ---------------------------------... |
/*
* 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 i... | text_layer_destroy(s_text_instructions) | ;
}
static void init(void) {
window = window_create();
window_set_click_config_provider(window, click_config_provider);
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
.unload = window_unload,
});
const bool animated = true;
window_stack_push(window, animated);
}
static ... |
nt16_t num_input_sessions,
ActivitySession *sessions) {
}
void activity_algorithm_minute_handler(time_t utc_sec, AlgMinuteRecord *record_out) {
s_test_alg_state.last_sleep_utc = utc_sec;
record_out->data.base.orientation = s_test_alg_state.orientation;
}
bool a... | for (int i = 0; i < num_samples; ) {
AccelData accel_data[ALGORITHM_SAMPLING_RATE];
for (int j = 0; j < ALGORITHM_SAMPLING_RATE; j++, i++) {
need_step_ctr -= 1;
accel_data[j] = (AccelData) {
.x = (num_steps > 0) && (need_step_ctr <= 0),
.y = sleep_state,
.z = 0,
.tim... |
PBL_ASSERTN(num_steps == 0);
}
// ---------------------------------------------------------------------------------------
// Feed in X seconds of raw data
static void prv_feed_raw_accel_data(AccelRawData *samples, uint32_t num_samples) {
time_t utc_secs;
uint16_t ms;
rtc_get_time_ms(&utc_secs, &ms);
uint64... |
_equal_b(true, ble_hrm_is_sharing_to_connection(&s_conn_a));
cl_assert_equal_b(true, ble_hrm_is_sharing());
prv_assert_event_service_subscribed(true);
// Revoke:
ble_hrm_revoke_sharing_permission_for_connection(&s_conn_a);
cl_assert_equal_b(false, ble_hrm_is_sharing_to_connection(&s_conn_a));
cl_assert_eq... | (&hrm_event) | ;
fake_event_service_handle_last();
if (expect_bt_driver_cb) {
cl_assert_equal_i(call_count_before + 1, s_bt_driver_hrm_service_handle_measurement_call_count);
cl_assert_equal_i(bpm, s_last_ble_hrm_measurement.bpm);
cl_assert_equal_b(expected_is_on_wrist, s_last_ble_hrm_measurement.is_on_wrist);
} el... |
return BTErrnoOK;
}
// -------------------------------------------------------------------------------------------------
void gap_le_connect_handle_bonding_change(BTBondingID bonding_id, BtPersistBondingOp op) {
// Load from flash outside of the bt_lock() block:
GAPLEConnectionIntentBonding updated_bonding;
i... | {
if (bonding_id == BT_BONDING_ID_INVALID || client >= GAPLEClientNum) {
return BTErrnoInvalidParameter;
}
bt_lock();
// Find the intent for the device:
GAPLEConnectionIntent *intent = prv_get_intent_by_bonding_id(bonding_id);
BTErrno ret_value;
if (!intent) {
// No intent for given device
ret... |
// -------------------------------------------------------------------------------------------------
void gap_le_connect_cancel_all(GAPLEClient client) {
bt_lock();
{
BLE_GAP_LOG_DEBUG("Cancel connecting all for client %u...", client);
GAPLEConnectionIntent *intent = s_intents;
while (intent) {
... |
/*
* 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 i... | window_set_fullscreen(window, s_next_window_fullscreen) | ;
window_set_window_handlers(window, (WindowHandlers) {
.unload = unload_handler,
});
window_set_click_config_provider(window, click_config_provider);
s_next_window_fullscreen = !s_next_window_fullscreen;
window_stack_push(window, true);
}
int main(void) {
push_window();
app_event_loop();
}
|
ning permissions and
* limitations under the License.
*/
#include "sharp_ls013b7dh01.h"
#include "applib/graphics/gtypes.h"
#include "board/board.h"
#include "debug/power_tracking.h"
#include "drivers/dma.h"
#include "drivers/gpio.h"
#include "drivers/periph_config.h"
#include "drivers/spi.h"
#include "kernel/util/... | (BOARD_CONFIG_DISPLAY.spi_gpio) | ;
if (BOARD_CONFIG.power_5v0_options != OptionNotPresent) {
// +5V to 5V_EN pin
gpio_output_set(&BOARD_CONFIG.power_ctl_5v0, true);
}
// +5V to LCD_DISP pin (Set this pin low to turn off the display)
gpio_output_set(&BOARD_CONFIG_DISPLAY.on_ctrl, true);
periph_config_release_lock();
}
uint32_t dis... |
sion 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 "A... | mutex_lock_recursive(s_recent_apps.mutex) | ;
{
RecentApp *app = circular_cache_get(&s_recent_apps.cache, &install_id);
if (app) {
const int32_t time_since_activity = time_get_uptime_seconds() - app->last_activity;
if (app->can_expire && (time_since_activity < VISIBILITY_ON_ACTIVITY_TIMEOUT_SECONDS)) {
// The recent app should event... |
lude "applib/rockyjs/api/rocky_api_global.h"
#include "applib/rockyjs/api/rocky_api_graphics.h"
#include "applib/rockyjs/api/rocky_api_graphics_color.h"
#include "applib/rockyjs/pbl_jerry_port.h"
// Standard
#include "string.h"
// Fakes
#include "fake_app_timer.h"
#include "fake_time.h"
// Stubs
#include "stubs_app_... | ("white", &GColorWhite) | ;
cl_assert_parsed_color("gray", &GColorLightGray);
}
extern const RockyAPIGraphicsColorDefinition s_color_definitions[];
void test_rocky_api_graphics_color__color_names_consistent(void) {
rocky_global_init(s_graphics_api);
const RockyAPIGraphicsColorDefinition *def = s_color_definitions;
while (def->name) ... |
.interval_min = 6, // 7.5ms
.interval_max = 24, // 30ms
.slave_latency = 4,
.sup_timeout = 600, // 6000ms
};
e = ble_gap_per_pref_conn_params_set(&preferred_params);
if (e != BLE_STATUS_OK) {
PBL_LOG(LOG_LEVEL_ERROR, "ble_gap_per_pref_conn_params_set: %u", e);
}
}
void ble_task_assert_is_execu... | if (notif & BLE_APP_NOTIFY_MASK) {
ble_evt_hdr_t *hdr;
hdr = ble_get_event(false);
if (!hdr) {
goto no_event;
}
if (ble_service_handle_event(hdr)) {
goto handled;
}
switch (hdr->evt_code) {
// GAP Events:
case BLE_EVT_GAP_CONNECTED:
... |
prv_handle_pairing_completed(evt);
break;
}
case BLE_EVT_GAP_ADDRESS_RESOLVED: {
const ble_evt_gap_address_resolved_t *evt = (const ble_evt_gap_address_resolved_t *)hdr;
prv_handle_address_resolved(evt);
break;
}
case BLE_EVT_GAP_DEV_A... |
circular_buffer__corner_case(void) {
SharedCircularBuffer buffer;
uint8_t storage[4];
shared_circular_buffer_init(&buffer, storage, sizeof(storage));
// Add a client
SharedCircularBufferClient client = (SharedCircularBufferClient) {};
shared_circular_buffer_add_client(&buffer, &client);
// We should sta... | cl_assert(shared_circular_buffer_write(
&buffer, (uint8_t*)"0k1m", 2*item_size, false)) | ;
items_read = shared_circular_buffer_read_subsampled(
&buffer, &client, item_size, out_buffer, 100);
cl_assert_equal_i(items_read, 3);
cl_assert_equal_m(out_buffer, "9j0k1m", 6);
}
void test_shared_circular_buffer__subsampling_variable_ratio(void) {
SharedCircularBuffer buffer;
uint16_t item_size = 2... |
/*
* 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 i... | (scroll_layer, (ScrollLayerCallbacks) {
.click_config_provider = (ClickConfigProvider) click_config_provider,
}) | ;
scroll_layer_set_context(scroll_layer, data);
scroll_layer_set_content_size(scroll_layer, GSize(window->layer.bounds.size.w, 500));
const GRect max_text_bounds = GRect(0, 0, window->layer.bounds.size.w, 500);
TextLayer *text = &data->text;
text_layer_init(text, &max_text_bounds);
text_layer_set_text(text... |
pliance 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... | comm_session_get_system_session() | ,
BtConsumerTimelineActionMenu, ResponseTimeMax, 0);
}
static WindowStack *prv_get_window_stack(ActionResultData *data) {
return window_manager_get_window_stack(data->voice_data ? ModalPriorityVoice :
ModalPriorityNotificat... |
/*
* 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 i... | (apple_ibeacon_ad_data, rssi, &ibeacon) | ;
BLEAdData *new_ibeacon_ad_data = ble_ad_create();
cl_assert_equal_b(ble_ibeacon_compose(&ibeacon, new_ibeacon_ad_data), true);
const size_t ad_data_size = apple_ibeacon_ad_data->ad_data_length +
apple_ibeacon_ad_data->scan_resp_data_length;
cl_assert_equal_i(new_ibeacon_ad_data... |
/*
* 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 i... | app_manager_put_launch_app_event(&(AppLaunchEventConfig) {
.id = app_install_id_to_launch,
.common.reason = APP_LAUNCH_USER,
.common.button = BUTTON_ID_SELECT,
}) | ;
}
static void prv_launcher_menu_layer_mark_dirty(LauncherMenuLayer *launcher_menu_layer) {
if (launcher_menu_layer) {
layer_mark_dirty(menu_layer_get_layer(&launcher_menu_layer->menu_layer));
}
}
//////////////////////////////////////
// LauncherAppGlanceService handlers
static void prv_glance_changed(void... |
;
cl_assert_equal_point_precise(PP(8.5, 9.5), s_graphics_line_draw_precise_stroked.last_call.pp0);
cl_assert_equal_point_precise(PP(10.5, 11.5), s_graphics_line_draw_precise_stroked.last_call.pp1);
EXECUTE_SCRIPT(
"ctx.fill();\n"
);
// only first shape has at least 3 points
cl_assert_equal_i(1, s_gpath... | EXECUTE_SCRIPT(
"ctx.beginPath();\n"
"ctx.moveTo(80, 40);\n"
"ctx.arc(60, 80, 20, 0, Math.PI, true);\n"
"ctx.stroke();\n"
) | |
gnature.
//
// Parses the ISR's circular buffer and collects assembled message into a message buffer. If
// a complete packets has been assembled, it returns a pointer to the message buffer,
// the size of the packet (in *msg_bytes), and the protocol (in *protocol). If a complete packet
// is not ready yet, it returns ... | state->hdr.len = ntohs(state->hdr.len);
// Validity checking
if (state->hdr.len > QEMU_MAX_DATA_LEN) {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid header data size %d", state->hdr.len);
state->recv_state = QemuRecvState_WaitingHdrSignatureMSB;
} else {
QEMU_LOG_DEBUG... | |
item, &bad_item.common.id));
}
void test_reminder_db__find_by_timestamp_title(void) {
prv_insert_default_reminders();
// Add items with title attributes for searching (out of order for worst-case scenario)
cl_assert(S_SUCCESS == reminder_db_insert_item(&title_item2));
cl_assert(S_SUCCESS == reminder_db_insert... | reminder_db_read((uint8_t *)&item1.header.id, sizeof(Uuid), (uint8_t *)&item,
sizeof(SerializedTimelineItemHeader)) | |
/*
* 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 i... | debug_print_str("LD CMD\n") | ;
struct __attribute__((packed)) {
uint32_t copy_address;
uint32_t length;
} send_data_cmd_payload = { };
prv_write_or_read_bytes(&send_data_cmd_payload, sizeof(send_data_cmd_payload), false);
debug_print_str_and_int(" Address:", send_data_cmd_payload.copy_address);
debug_print_st... |
t(test_image_color, 30, 30) == 1);
#elif SCREEN_COLOR_DEPTH_BITS == 8
cl_check(gcolor_equal(get_bitmap_color(test_image_bw, 8, 16), GColorWhite));
cl_check(gcolor_equal(get_bitmap_color(test_image_bw, 8, 24), GColorBlack));
cl_check(gcolor_equal(get_bitmap_color(test_image_color, 30, 2), GColorClear));
cl_check... | DEG_TO_TRIGANGLE(45) | , GPoint(20, 20));
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rotated_bitmap_offset_bw_center_45.Xbit.pbi"));
}
void test_graphics_draw_rotated_bitmap__origin_color_assign(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// No Clip, Angle 0
setup_test_rotate_bitmap(&ctx, fb, ORIGIN_RECT_NO_C... |
-------
static void cur_temp_update_text(TemperatureDemoAppData *data) {
// Show current temp
int cur_temp = temperature_read();
snprintf(data->cur_temp_text, sizeof(data->cur_temp_text), "%d", cur_temp);
text_layer_set_text(data->cur_temp_layer, data->cur_temp_text);
snprintf(data->temp_range_text, sizeof(d... | text_layer_set_font(data->temp_range_layer,
fonts_get_system_font(FONT_KEY_LECO_20_BOLD_NUMBERS)) | ;
text_layer_set_background_color(data->temp_range_layer, GColorClear);
text_layer_set_text_color(data->temp_range_layer, GColorBlack);
layer_add_child(window_layer, text_layer_get_layer(data->temp_range_layer));
// Update UI
cur_temp_update_text(data);
// Subscribe to second tick for updates
tick_timer... |
/*
* 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 i... | (PROTOC_PATH" --proto_path="TINTIN_PATH""PROTO_PATH" --decode=pebble.pipeline.Payload "
""TINTIN_PATH""PROTO_PATH"/payload.proto < "TMP_FILE" 2>&1") | ;
}
|
unsigned int selected_index,
unsigned int additional_crumbs) {
prv_prepare_canvas_and_render_for_each_size(
prv_render_action_menus_static, root_level, selected_index, 1 /* num_rows */,
additional_crumbs);
}
void prv_prepare_canvas... | (gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_action_menu_window__thin_display_mode_one_item(void) {
static const char* thin_values[] = { "Y" };
ActionMenuLevel *root_level = action_menu_level_create(ARRAY_LENGTH(thin_values));
action_menu_level_set_display_mode(root_level, ActionMenuLevelDisplayModeThin);
for (size_t i = 0; i < ARRAY_LENGTH... |
total);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls... | prv_count_handler_entries(&s_stopped_handler_calls, c) | , 1);
// If we keep going, we should repeat the whole sequence
prv_advance_to_ms_with_timers(start_ms + 2 * (duration_total + 4 * MIN_FRAME_INTERVAL_MS));
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 3);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 2);... |
the timeout for the in-flight packets
// This will trigger a retransmit of the un-acked packets
for (int i = 0; i < PPOGATT_TIMEOUT_TICKS - 1; ++i) {
regular_timer_fire_seconds(PPOGATT_TIMEOUT_TICK_INTERVAL_SECS);
}
fake_comm_session_process_send_next();
for (sn = 0; sn < s_tx_window_size; ++sn) {
... | (&s_meta_v0_system.app_uuid) | ;
uint8_t num_packets = s_tx_window_size;
// Get a packet in flight:
for (int sn = 0; sn < num_packets; sn++) {
cl_assert_equal_b(
fake_comm_session_send_buffer_write_raw_by_transport(
transport, s_short_data_fragment, sizeof(s_short_data_fragment) - sn), true);
ppogatt_send_next(transpo... |
letBytes(PostMessageKeyResetComplete, \
(const uint8_t *) &VALID_RESET_COMPLETE, \
sizeof(VALID_RESET_COMPLETE)));
////////////////////////////////////////////////////////////////////////////////
// Negotiation Steps
//////////////... | cl_assert_equal_i(rocky_api_app_message_get_state(), PostMessageStateAwaitingResetRequest) | ;
EXPECT_OUTBOX_NO_MESSAGE_PENDING();
}
void test_rocky_api_app_message__awaiting_reset_complete_rem_init__malformed_reset_complete(void) {
prv_init_and_goto_awaiting_reset_complete_remote_initiated();
// Receive malformed ResetComplete:
uint8_t malformed_payload[sizeof(PostMessageResetCompletePayload) - 1] =... |
spatch_touch_event(r, &ctx));
cl_assert(handled);
cl_assert_equal_p(ctx.triggered, s);
}
bool prv_fail_recognizer(Recognizer *recognizer, void *context);
void test_recognizer_manager__fail_recognizer(void) {
NEW_RECOGNIZER(r1) = test_recognizer_create(&s_test_impl_data, NULL);
NEW_RECOGNIZER(r2) = test_recog... | (recognizers[3]->state, RecognizerState_Cancelled) | ;
// If recognizers are in the possible state, they will be failed, rather than cancelled
prv_set_all_states(recognizers, k_rec_count, RecognizerState_Possible);
prv_cancel_layer_tree_recognizers(&manager, NULL, &layer_c);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(... |
est_entry.version == 3) {
sscanf(token + strlen(token) + 1, "%d, 0x%x, %d, %d, %d", &steps, &orientation, &vmc,
&light, &plugged_in);
} else {
cl_assert(false);
}
fflush(stdout);
PBL_ASSERTN(state->test_entry.num_samples < SLEEP_SAMPLES_DISCOVERY_MAX_SAMPLES);
... | } else if (strcmp(token, "TEST_WEIGHT") == 0) {
sscanf(token + strlen(token) + 1, "%f", &state->test_entry.weight);
} else if (strcmp(token, "TEST_NAME") == 0) {
sscanf(token + strlen(token) + 1, "%s", state->test_entry.name);
} |
}
// If this is a "static AlgDlsMinuteData samples[] = {" line, skip it
if (strcmp(token, "static") == 0) {
continue;
}
// Grab a sample
if (strcmp(token, "{") == 0) {
PBL_ASSERTN(state->test_entry.name[0] != 0);
int steps = 0;
int orientation = 0;
int vmc = 0;
... |
+ (i * WAKEUP_EVENT_WINDOW), 0, false);
cl_assert_equal_i(sys_wakeup_query(wakeup_id), sys_get_time() + (i * WAKEUP_EVENT_WINDOW));
}
// Test that the 9th wakeup event fails to schedule (E_DOES_NOT_EXIST)
wakeup_id = sys_wakeup_schedule(sys_get_time() + ((MAX_WAKEUP_EVENTS_PER_APP + 1) * WAKEUP_EVENT_WINDOW... | (sys_wakeup_query(third_wakeup_id), third_event) | |
quested_resource_the_default_icon &&
!prv_app_resource_info_equal(&generic_glance->displayed_icon_resource_info,
&generic_glance->default_icon_resource_info));
const bool is_icon_stale =
(!prv_app_resource_info_equal(&generic_glance->displayed_icon_resource_info, res_i... | rtc_get_time() | |
/*
* 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 i... | if (ctx->triggered && !recognizer_should_evaluate_simultaneously(recognizer, ctx->triggered)) {
recognizer_set_failed(recognizer);
} |
ctx->recognizers_active = recognizer_is_active(recognizer);
return true;
}
static bool prv_fail_other_recognizers(RecognizerManager *manager) {
FailRecognizerCtx ctx = {
.triggered = manager->triggered,
};
prv_process_all_recognizers(manager, prv_fail_recognizer, &ctx);
return ctx.recognizers_active;
... |
/*
* 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 i... | malloc(sizeof(FrameBuffer)) | ;
fb->size = (GSize) {DISP_COLS, DISP_ROWS};
}
// Teardown
void test_kino_reel__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
void test_kino_reel__resource_gbitmap(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Test loading GBitmap Kino Reel
uint32_t resource_... |
1,
.attributes = (Attribute[1]) {{ .id = AttributeIdTitle, .cstring = "test 1" }}
}
};
static TimelineItem title_item2 = {
.header = {
.id = {0xac, 0x65, 0x2e, 0xb9, 0x26, 0xd6, 0x44, 0x2c,
0x98, 0x68, 0xa4, 0x36, 0x79, 0x7d, 0xe2, 0x05},
.timestamp = 1,
.duration = 0,
.type = Time... | (S_SUCCESS == reminder_db_delete_item(&temp.header.id, true /* send_event */)) | ;
cl_assert(reminder_db_get_len((uint8_t *) &item4, sizeof(Uuid)) == 0);
memset(&temp, 0, sizeof(TimelineItem));
cl_assert(S_SUCCESS == reminder_db_next_item_header(&temp));
temp.attr_list.attributes = NULL;
cl_assert(memcmp(&item3, &temp, sizeof(TimelineItem)) == 0);
cl_assert(S_SUCCESS == rem... |
s.num_calls == 2);
cl_assert(detected_reset_of_elapsed);
// Make sure the frame reached the "to" state
cl_assert_equal_point(layer.frame.origin, to_r.origin);
#endif
}
// --------------------------------------------------------------------------------------
// Test that auto-destroy works correctly
void test_... | (prv_count_animations(), 0) | |
{
// Device got disconnected in the mean time
return 0;
}
const uint16_t num_bytes_overhead = 3 /* ATT header */ + sizeof(PPoGATTPacket);
return (mtu - num_bytes_overhead);
}
// -------------------------------------------------------------------------------------------------
static void prv_enter_await... | {
if (++s_disconnect_counter > PPOGATT_DISCONNECT_COUNT_MAX) {
// only log this the first couple of times it happens
if (s_disconnect_counter < (PPOGATT_DISCONNECT_COUNT_MAX + 3)) {
PBL_LOG(LOG_LEVEL_ERROR, "Not disconnecting because max disconnects reached...");
}
return;
} else... |
prv_enter_awaiting_reset_complete(client, true /* self_initiated */);
}
// -------------------------------------------------------------------------------------------------
static void prv_handle_reset_request(PPoGATTClient *client) {
if (client->state == StateConnectedClosedAwaitingResetCompleteSelfInitiatedRes... |
/*
* 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 i... | phone_format_caller_name("Pankajavalli", dest, buffer_length) | ;
cl_assert_equal_s(dest, "Pankajava");
cl_assert_equal_m(dest + buffer_length, GUARD_REFERENCE, NAME_LENGTH - buffer_length);
}
void test_phone_formatting__overflowing_first_name(void) {
const size_t buffer_length = 10;
char dest[NAME_LENGTH];
memset(dest, GUARD_CHAR, NAME_LENGTH);
phone_format_caller_n... |
d_crc == expected_crc);
}
static bool prv_send_vt(const uint8_t *vt, uint32_t vt_size_bytes) {
uint8_t vt_write[] = {'V', 'T'};
dialog_spi_transmit_data(vt_write, sizeof(vt_write));
uint8_t entries = vt_size_bytes / 4;
dialog_spi_transmit_data((uint8_t *)&entries, sizeof(entries));
dialog_spi_wait_for_int(... | (image_size, &info) | ) {
return false;
}
return true;
}
static void prv_issue_bt_reboot(void) {
uint8_t reboot[] = {'R', 'T'};
dialog_spi_transmit_data(reboot, sizeof(reboot));
}
static bool prv_load_bt_image_over_spi(void) {
PBL_LOG(LOG_LEVEL_DEBUG, "Bringing up the BT Stack");
if (!prv_send_hi_cmd()) {
PBL_LOG(LOG... |
/*
* 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 i... | {
prv_test_plot_horizontal_line(&ctx.dest_bitmap,
GRect(OFFSET_X, OFFSET_Y + i, STRIPE_WIDTH, STRIPE_HEIGHT),
(GColor){.argb = color | alpha});
color++;
} |
// Compare the results
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "blendtest_0_100.pbi"));
// Reset canvas
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_bitmap_in_rect(&ctx, background_33_66, &ORIGIN_RECT_NO_CLIP);
// 33% alpha channel blend test
color = ... |
nt, 3 * ANIMATION_FRAME_MS);
Animation *ui_bounceback = property_animation_get_animation(
property_animation_create_bounds_origin(
&s_phone_ui_data->core_ui_container, &overshoot,
&GPoint(PBL_IF_RECT_ELSE(ACTION_BAR_WIDTH / 2, 0), 0)));
animation_set_curve(ui_bounceback, AnimationCurveEaseOut)... | {
timeline_item_destroy(item);
} |
attribute_list_destroy_list(&attributes);
ios_notif_pref_db_free_prefs(notif_prefs);
return rv;
}
//! Action bar click configurations
static void prv_click_config_provider(void *context) {
if (s_phone_ui_data->up_action) {
window_single_click_subscribe(BUTTON_ID_UP, s_phone_ui_data->up_action);
}
i... |
int;
if (current_codepoint == NEWLINE_CODEPOINT) {
if (is_newline_as_space) {
current_codepoint = SPACE_CODEPOINT;
} else {
break;
}
}
next_glyph_width_px = prv_codepoint_get_horizontal_advance(&ctx->font_cache,
text_box_params->font, current_codepoint);
}
// ... | is_clip_box_overflow_bottom_stop_condition_cb(ctx, line, text_box_params) | |
c_contains_pairing_info(&pairing_3, false), false);
}
void test_bluetooth_persistent_storage_prf__get_ble_by_address(void) {
bool ret;
// Output variables
SMIdentityResolvingKey irk_out;
// Store a pairing
SMPairingInfo pairing = (SMPairingInfo) {
.irk = (SMIdentityResolvingKey) {
.data = {
... | {
bool ret;
// Output variables
BTDeviceAddress addr_out;
SM128BitKey link_key_out;
char name_out[BT_DEVICE_NAME_BUFFER_SIZE];
uint8_t platform_bits_out;
// Store a new pairing
BTDeviceAddress addr_1 = {.octets = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16}};
SM128BitKey link_key_1 = {
.data = {
0... |
BTBondingID id_2 = bt_persistent_storage_store_bt_classic_pairing(&addr_2, &link_key_2,
name_2, &platform_bits_2);
prv_fire_writeback_timer();
cl_assert(id_2 != BT_BONDING_ID_INVALID);
// Read it pairings back (purposefully using the wrong bonding ID... |
data_out->ppg[i] = ntohs(ppg_reading.ppg);
data_out->tia[i] = ntohs(ppg_reading.tia);
success = true;
break;
}
PPG_DBG_VERBOSE("FAIL: got %"PRIu16" expected %u tia %"PRIu16,
ppg_reading.idx, i + 1, ntohs(ppg_reading.tia));
// Keep trying...
}
... | {
prv_write_accel_sample(HRM, i + 1, &accel_data->data[i]);
} |
data.accel_data = *accel_data;
hrm_manager_release_accel_data();
// Read the rest of the HRM data fields.
prv_read_hrm_data(HRM, &data);
// Handle the clock skew register
uint32_t average_handshake_interval_ms;
uint32_t num_intervals = interval_timer_get(&s_handshake_interval_timer,
... |
e the License for the specific language governing permissions and
* limitations under the License.
*/
#include "debug.h"
#include "advanced_logging.h"
#include "flash_logging.h"
#include "debug_reboot_reason.h"
#include "drivers/watchdog.h"
#include "flash_region/flash_region.h"
#include "kernel/events.h"
#include... | PBL_LOG(LOG_LEVEL_ERROR, "Already in the middle of dumping logs") | ;
return;
}
prv_put_status_event(DebugInfoStateStarted);
// Temporarily disable logging so we don't log forever.
flash_logging_set_enabled(false);
s_bt_dump_chunk_callback_data.in_progress = true;
s_bt_dump_chunk_callback_data.generation = generation;
s_bt_dump_chunk_callback_data.comm_session = se... |
} else if (strcmp(token, "TEST_WEIGHT") == 0) {
sscanf(token + strlen(token) + 1, "%f", &state->test_entry.weight);
} else if (strcmp(token, "TEST_NAME") == 0) {
sscanf(token + strlen(token) + 1, "%s", state->test_entry.name);
}
}
// If this is a "static AlgDlsMinuteData samples[] =... | {
token = strtok(NULL, " \t\n");
if (strcmp(token, "TEST_VERSION") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.version);
} else if (strcmp(token, "TEST_ACTIVITY_TYPE") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.activity_type.value);
... | |
prv_assert_client_event(&device, true /* connected */, (1 << PebbleTask_KernelMain),
HCI_ERROR_CODE_SUCCESS) | ;
// Register connection intent for app:
e = gap_le_connect_connect_by_bonding(bonding_id,
true /* auto_reconnect */,
false /* is_pairing_required */,
GAPLEClientApp);
cl_assert_equal_i(e, BTEr... | |
(&ctx, "blue33", &s_font_info, GRect(10, 70, 100, 30),
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL) | ;
ctx.draw_state.text_color.a = 0;
graphics_draw_text(&ctx, "blue0", &s_font_info, GRect(10, 100, 100, 30),
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_color_assign.8bit.pbi"));
setup_test_aa_sw(&ctx, fb, GRect(0, 0, 14... | |
36, 240, -888},
{ 368, 168, -904},
{ 336, 216, -888},
{ 368, 64, -872},
// 150 seconds
{ 312, 176, -864},
{ 352, 0, -880},
{ 296, 360, -840},
{ 400, 352, -744},
{ 240, 760, -800},
{ 336, 440, -792},
{ 320, 536, -760},
{ 368, 288, -840},
{ 392, 592, -800},
{ 336, 5... | { 272, 696, -936},
{ 512, 48, -744},
{ 264, 296, -776},
{ 320, 376, -848},
{ 384, 360, -832},
{ 392, 336, -856},
{ 400, 456, -816},
{ 384, 384, -816},
{ 360, 336, -824},
{ 376, 360, -816},
{ 384, 328, -824},
{ 376, 408, -808},
{ 368, 368, -816},
{ 376, 360, -824},... |
{ 432, 576, -728},
{ 408, 544, -776},
{ 280, 440, -816},
{ 256, 528, -736},
{ 344, 224, -816},
{ 264, 536, -816},
{ 544, 88, -792},
{ 552, 432, -752},
{ 424, 944, -648},
{ 416, 600, -704},
{ 352, 400, -680},
{ 360, 336, -816},
{ 376, 392, -808},
{ 352, 592, -768}... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.