prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* 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... | while (millis--) {
delay_us(1000);
} |
}
|
("a", string_list_get_at(list, 3)) | ;
}
| |
/*
* 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... | {
gdraw_command_list_attract_to_square(&image->command_list, image->size, normalized);
} |
////////////////////
// gpoint index lookup creator
typedef struct {
const struct {
const GPoint *points;
uint16_t num_points;
} values;
struct {
GPointIndexLookup *lookup;
uint32_t current_index;
} iter;
} GPointCreateIndexCBContext;
T_STATIC bool prv_gdraw_command_create_point_index_looku... |
HONE_EVENT,
.phone = {
.type = PhoneEventType_Disconnect,
.source = PhoneCallSource_PP,
.call_identifier = 0, // Cookie is not yet implemented / used
}
};
event_put(&e);
}
static void prv_put_call_end_event(void) {
PebbleEvent e = {
.type = PEBBLE_PHONE_EVENT,
.phone = {
.... | if (prv_parse_msg_to_event(msg, length, &e, is_state_response)) {
event_put(&e);
} |
}
void phone_protocol_msg_callback(CommSession *session, const uint8_t* iter, size_t length) {
PBL_HEXDUMP(LOG_LEVEL_DEBUG, iter, length);
// Get State Response is basically a list representing the state of current calls. It's
// conveniently formatted exactly the same as the event messages, so just loop over ... |
/*
* 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_create() | |
/*
* 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... | (!iter_next(&char_iter)) | ;
cl_assert(!iter_next(&char_iter));
}
void test_char_iterator__decode_test_string_with_formatting_char(void) {
Iterator char_iter;
CharIterState char_iter_state;
Utf8IterState* utf8_iter_state = (Utf8IterState*) &char_iter_state.utf8_iter_state;
// Skip over codepoints that aren't newline and < 0x20
bool... |
ipsis_clip_across_ny_descender(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(0, -25, 100, 32),
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
// Ellipsis Tests
void draw_text_single_l... | (ctx, s_text_buffer, &s_font_info, GRect(-44, 4, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL) | ;
}
void draw_text_single_line_wordwrap_clip_across_x(Layer* me, GContext* ctx) {
graphics_context_set_text_color(ctx, GColorBlack);
graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(34, 4, 72, 32),
GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
void draw_text_single_line_... |
.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_rand_ptr.h"
#include "stubs_tick.h"
void core_dump_reset(bool is_forced) {
}
void launcher_task_add_callback(void (*callback)(void *data), void *data) {
callback(data);
}
uint16_t gaps_get_starting_att_handle(void) {
return 4;
}
// Helpers
... | (event.task_mask, task_mask) | ;
BLECharacteristic characteristic_out;
uint8_t *buffer = (uint8_t *) malloc(assert_value_length);
memset(buffer, 0, assert_value_length);
if (kernel) {
GATTBufferedNotificationHeader header = {};
gatt_client_subscriptions_get_notification_header(GAPLEClientKernel, &header);
cl_assert_equal_i(heade... |
5, WDAY_ANY, 1447332300},
// hour
// 2015 Nov 12, 13:00:00
{ -1,-1,13,-1, WDAY_ANY, 1447333200},
// hour+minute
// 2015 Nov 12, 13:45:00
{ -1,-1,13,45, WDAY_ANY, 1447335900},
// mday
// 2015 Nov 13, 00:00:00
{ -1,12,-1,-1, WDAY_ANY, 1447372800},
// mday+minute
// 2015 Nov 13, 00:45:00
{ -1,12,-1... | (&s_timezone_gmt, &test_cron, base, advance, advance, 2) | ;
}
}
void test_cron__dst_simple_to(void) {
// Nov 21st, 01:00:00 local
CronJob test_cron = {
.cb = prv_cron_callback,
.cb_data = (void*)0,
.minute = 0,
.hour = 1,
.mday = 20,
.month = 10,
.may_be_instant = true,
};
// 2015 Nov 21, 00:00:00 GMT
const time_t advance = 144806400... |
/*
* 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... | { 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 142},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 142},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0,... |
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 144},
{ 0, 0x7b, 0, 141},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 142},
{ 0, 0x7b, 0, 144},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 145},
{ 0, 0x7b, 0, 144},
{ 0... |
CAPABILITY_HAS_BUILTIN_HRM
case RXMenuIdx_HRM:
data->is_hrm_enabled = !data->is_hrm_enabled;
menu_layer_reload_data(menu_layer);
break;
#endif
#if CAPABILITY_HAS_MICROPHONE
case RXMenuIdx_Microphone:
data->is_mic_enabled = !data->is_mic_enabled;
menu_layer_reload_dat... | {
AppData *data = app_malloc_check(sizeof(*data));
*data = (AppData) {
.current_test = BTLETestType_None,
.current_test_step = BTLETestStep_None,
.btle_test_semaphore = xSemaphoreCreateBinary(),
};
app_state_set_user_data(data);
window_init(&data->main_menu_window, "");
window_init(&data->txrx... |
const PebbleProcessMd* mfg_btle_app_get_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common.main_func = &prv_main,
.name = "Test BTLE",
};
return (const PebbleProcessMd*) &s_app_info;
}
#endif // BT_CONTROLLER_DA14681
|
/*
* 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_set_text(&data->text, data->text_buffer) | |
ber();
cl_assert_equal_s(serial, "XXXXXXXXXXXX");
// Test writing & reading back:
const char* written_serial1 = "ABCDEFGHIJKL";
command_serial_write(written_serial1);
serial = mfg_get_serial_number();
cl_assert_equal_s(written_serial1, serial);
}
void test_mfg_serials__pcba_serial_number(void) {
const c... | (r, MfgSerialsResultSuccess) | ;
cl_assert_equal_s(sn, fifth_sn);
cl_assert_equal_i(index, 6); // SERIAL5 lives at index 6
// No more space:
const char *sixth_sn = "XXXXXXXXXXXX";
r = mfg_write_serial_number(sixth_sn, strlen(sixth_sn), &index);
cl_assert(r == MfgSerialsResultFailNoMoreSpace);
}
|
ob(job);
if (is_registered) {
PBL_LOG(LOG_LEVEL_INFO, "Unscheduling advertising job: %s",
prv_string_for_debug_tag(job->tag));
prv_unlink_job(job);
prv_perform_next_job(false);
// Call the unscheduled callback:
if (job->unscheduled_callback) {
job->unscheduled_... | (ANALYTICS_DEVICE_METRIC_BLE_ESTIMATED_BYTES_ADVERTISED_COUNT) | ;
}
unlock:
bt_unlock();
}
// -----------------------------------------------------------------------------
void gap_le_advert_handle_disconnect_as_slave(void) {
bt_lock();
{
if (!s_gap_le_advert_is_initialized) {
goto unlock;
}
// Call prv_perform_next_job() to trigger refreshing the configu... |
= s_profile_info_functions[i]()) != NULL)
static const SmartstrapProfileGetInfoFunc s_profile_info_functions[] = {
#define REGISTER_SMARTSTRAP_PROFILE(f) f,
#include "services/normal/accessory/smartstrap_profile_registry.def"
#undef REGISTER_SMARTSTRAP_PROFILE
};
// every profile except for SmartstrapProfileInvalid sh... | smartstrap_is_connected() | ) {
PBL_LOG(LOG_LEVEL_WARNING, "Dropped notification due to not being connected.");
return;
}
// dispatch the notification based on the profile
const SmartstrapProfileInfo *info = prv_get_info_by_profile(profile);
if (info && info->notify) {
smartstrap_state_lock();
info->notify();
smartstr... |
MBER_SIZE)) || (serial[serial_size] != '\0')) {
return MfgSerialsResultFailIncorrectLength;
}
return prv_mfg_write_data_to_slot(OTP_SERIAL_SLOT_INDICES, ARRAY_LENGTH(OTP_SERIAL_SLOT_INDICES),
serial, serial_size, out_index);
}
MfgSerialsResult mfg_write_pcba_serial_number(c... | (&serial_number[i], 3 /* 2 hex digits + zero terminator */, "%02X",
DEVICE_ID_REGISTER[r]) | ;
}
serial_number[MFG_SERIAL_NUMBER_SIZE] = 0;
}
static bool prv_get_more_unique_serial(char *serial_number) {
for (int i = 2; i < MFG_SERIAL_NUMBER_SIZE; i += 2) {
sniprintf(&serial_number[i], 3 /* 2 hex digits + zero terminator */, "%02X", rand());
}
serial_number[MFG_SERIAL_NUMBER_SIZE] = 0;
return ... |
s) {
.stopped = prv_update_icon,
}, new_bitmap);
Animation *sequence = animation_sequence_create(disappear_animation, bounceback_animation, NULL);
data->cassette_current_icon = new_bitmap;
animation_schedule(sequence);
}
static void prv_skipping_click_config_provider(void *data);
static void prv_volume... | prv_change_volume(is_volume_up) | ;
// Trigger haptic feedback only on repeat
if (click_number_of_clicks_counted(recognizer) >= 2) {
prv_do_haptic_feedback_vibe(context);
}
}
static void prv_ellipsis_click_handler(ClickRecognizerRef recognizer, void *context) {
MusicAppData *data = context;
data->action_bar_revert_timer = app_timer_regi... |
o.h"
#ifdef DEBUG_BATTERY_STATE
#define BATTERY_SAMPLE_RATE_MS 1000
#else
#define BATTERY_SAMPLE_RATE_MS (60 * 1000)
#endif
typedef void (*EntryFunc)(void);
typedef enum {
ConnectionStateInvalid,
ConnectionStateChargingPlugged,
ConnectionStateDischargingPlugged,
ConnectionStateDischargingUnplugged
} Connecti... | {
const bool charging = battery_charge_controller_thinks_we_are_charging();
const bool plugged_in = battery_is_usb_connected();
if (plugged_in) {
if (charging) {
return ConnectionStateChargingPlugged;
} else {
return ConnectionStateDischargingPlugged;
}
} else {
if (charging) {
... |
static void prv_update_state(void *force_update) {
const uint8_t MAX_SAMPLE_SKIPS = 5;
bool forced = (bool)force_update;
// Large current draws will cause the voltage supplied by the battery to
// droop. We try to only sample the battery when there is minimal
// activity. We look to see if stop mode is allo... |
/*
* 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... | {
AppSync *s = context;
if (s->callback.value_changed) {
s->callback.value_changed(key, new_tuple, old_tuple, s->callback.context);
}
} |
static void pass_initial_values_app_task_callback(void *data) {
AppSync *s = data;
Tuple *tuple = dict_read_first(&s->current_iter);
while (tuple) {
update_key_callback(tuple->key, tuple, NULL, s);
tuple = dict_read_next(&s->current_iter);
}
}
static void update_callback(DictionaryIterator *updated_i... |
orizontal_line_dotted(&ctx, GPoint(100, 95), 5);
// T facing left - odd vert, odd horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(131, 91), 10);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(131, 96), 5);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, TEST_NAMED_PBI_FILE("draw_dotted_line_cross")));
}
v... | graphics_context_set_antialiased(ctx, false) | ;
graphics_context_set_stroke_width(ctx, 2);
graphics_draw_line(ctx, GPoint(30,30), GPoint(30,30));
graphics_context_set_antialiased(ctx, true);
graphics_context_set_stroke_width(ctx, 2);
graphics_draw_line(ctx, GPoint(40,40), GPoint(40,40));
graphics_context_set_antialiased(ctx, false);
graphics_contex... |
peek format data (QemuProtocol_TimelinePeek)
static void prv_timeline_peek_msg_callback(const uint8_t *data, uint32_t len) {
QemuProtocolTimelinePeekHeader *hdr = (QemuProtocolTimelinePeekHeader *)data;
if (len != sizeof(*hdr)) {
PBL_LOG(LOG_LEVEL_ERROR, "Invalid packet length");
return;
}
PBL_LOG(LOG_... | handler->callback(msg_ptr, msg_bytes) | ;
}
}
}
// -----------------------------------------------------------------------------------------
static bool prv_uart_irq_handler(UARTDevice *dev, uint8_t byte, const UARTRXErrorFlags *err_flags) {
// The interrupt triggers when a byte has been read from the UART. QEMU's
// emulated UARTs don't emulate ... |
/*
* 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 false;
} |
ResAppNum sys_get_current_resource_num(void) {
return 0;
}
const uint8_t *sys_resource_read_only_bytes(ResAppNum app_num, uint32_t resource_id,
size_t *num_bytes_out) {
return NULL;
}
// Fakes
///////////////////////
size_t s_resource_size;
size_t sys_resource_size(Re... |
{
return;
}
// Cancel any outstanding timer.
prv_stop_timer(outbox);
outbox->transmission_size_limit = 0;
applib_free(outbox->app_outbox_message);
outbox->app_outbox_message = NULL;
// Finish by moving to the next phase.
outbox->phase = OUT_CLOSED;
}
static void prv_throttle(AppMessageCtxOutbox ... | (LOG_LEVEL_ERROR, "Can't call app_message_outbox_send() now, wait for sent_callback!") | ;
return APP_MSG_BUSY;
}
if (outbox->phase != OUT_WRITING) {
return APP_MSG_INVALID_STATE;
}
const size_t transmission_size = dict_write_end(&outbox->iterator) + APP_MSG_HDR_OVRHD_SIZE;
if (transmission_size > outbox->transmission_size_limit) {
return APP_MSG_BUFFER_OVERFLOW;
}
uint8_t trans... |
t height = 2 * (max_height + 1); // Add one more pixel in case on the edge
// add two pixels just in case of rounding isssues
const int32_t max_distance = integer_sqrt((width * width) + (height * height)) + 2;
const int32_t min_x = src_ic.x - max_distance;
const int32_t min_y = src_ic.y - max_distance;... | (actual_color, dst_color) | ;
break;
}
}
case GCompOpAssign:
default:
// Do assign by default
ctx->draw_state.stroke_color = src_color;
break;
}
ctx->draw_state.stroke_color.a = 3; // Force to be opaque
graphics_private_set_pixel(ctx, GPoint(x, y));
#en... |
eys and values. This reduces
// our usable space to slightly less than 2048 bytes.
for (int i = 0; i < 128; i++) {
snprintf((char *)key, sizeof(key), "k%03d", i);
snprintf((char *)val, sizeof(val), "v%03d", i);
printf("Iteration %d val %s\n", i, val);
set_and_verify(&file, key, key_len, val, val_len... | ("\nTesting if we really are atomic...\n") | ;
bool have_hit_old_value = false;
bool have_hit_new_value = false;
bool have_hit_end = false;
for (int i = 1; i < 50; i++) {
printf("Iteration %3d... ", i);
RecordResult result = write_and_change_record_aborting_after_bytes(i);
switch (result) {
case RecordResultOld:
have_hit_old_valu... |
pMessageCtx *app_state_get_app_message_ctx(void) {
return &s_app_state_ptr->app_message_ctx;
}
#if !defined(PLATFORM_TINTIN)
BLEAppState* app_state_get_ble_app_state(void) {
return &s_app_state_ptr->ble_app_state;
}
#endif
ClickManager* app_state_get_click_manager() {
return &s_app_state_ptr->click_manager;
}
... | {
return s_app_state_ptr->rocky_memory_api_context;
} |
void app_state_set_rocky_memory_api_context(RockyMemoryAPIContext *context) {
s_app_state_ptr->rocky_memory_api_context = context;
}
ApplibInternalEventsInfo *app_state_get_applib_internal_events_info(void) {
return &s_app_state_ptr->applib_internal_events_info;
}
TextRenderState *app_state_get_text_render_stat... |
0},
{ -16, 936, 184},
{ -16, 936, 184},
{ -16, 936, 192},
{ -16, 936, 192},
{ -24, 936, 192},
{ -16, 928, 184},
{ -24, 936, 168},
{ -32, 928, 216},
{ -24, 928, 200},
{ -16, 936, 176},
{ -24, 936, 192},
{ -24, 928, 208},
{ -24, 928, 184},
{ -24, 936, 192},
{ -2... | { -24, 928, 208},
// 60 seconds
// elapsed: 1 minutes
{ -24, 920, 192},
{ -16, 936, 192},
{ -24, 928, 192},
{ -16, 928, 184},
{ -24, 928, 184},
{ -16, 936, 200},
{ -16, 928, 200},
{ -24, 936, 192},
{ -24, 936, 184},
{ -24, 936, 192},
{ -16, 928, 184},
{ -24, 9... |
{ -40, 920, 248},
{ -32, 920, 248},
{ -32, 920, 232},
{ -40, 928, 248},
{ -32, 920, 256},
{ -32, 920, 248},
{ -40, 920, 248},
// 63 seconds
{ -40, 928, 240},
{ -40, 920, 248},
{ -32, 920, 240},
{ -32, 920, 248},
{ -32, 920, 240},
{ -32, 920, 248},
{ -40, 920,... |
1].header.id) ||
uuid_equal(&state.pin.header.id, &s_all_day_items[2].header.id));
cl_assert(state.node->all_day);
// check that the item we see is timestamped at local midnight rather than utc midnight
// 1421136000 is midnight Jan 13, PST
cl_assert_equal_i(state.pin.header.timestamp, 1421136000);
// se... | (uuid_equal(&state.pin.header.id, &s_all_day_items[0].header.id)) | ;
cl_assert(!iter_next(&iterator));
}
static void prv_insert_extra_case_items(void) {
pin_db_flush();
for (int i = 0; i < ARRAY_LENGTH(s_extra_case_items); i++) {
cl_assert_equal_i(pin_db_insert_item(&s_extra_case_items[i]), 0);
}
}
// 5am, no events passed
void test_timeline__extra_case_forwards(void) {... |
///////////
void test_clock__initialize(void) {
// Setup resources
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false);
resource_init();
}
extern void prv_update_time_info_and_generate_event(time_t *t, TimezoneInfo *... | time_utc_to_local(rtc_get_time()) | , jan1st_noon_2005);
}
}
}
#define DST_ID_COUNT 36
static const time_t s_dst_correct_values[DST_ID_COUNT][3] = {
/* No DST: 0 ~ 0, GMT+0 */
[ 0]={ 0, 0, 0 },
/* AN (New South Wales) [Australia/Sydney]
Rule AN 2008 max - Apr Sun>=1 2:00s 0 S
Rule AN 2008 max - Oct Sun>=1 2:00s 1:00 D
... |
/*
* 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... | snprintf(name, buf_len, "ps%06d", pid) | ;
}
status_t persist_service_delete_file(const Uuid *uuid) {
char name[PERSIST_FILE_NAME_MAX_LENGTH];
status_t status = prv_get_file_name(name, sizeof(name), uuid);
if (FAILED(status)) {
return status;
}
return pfs_remove(name);
}
static bool prv_bad_persist_file_filter(const char *filename) {
return... |
gcolor_equal(GColorRed, GColorBlue));
// Two colors with zero alpha values should be equal regardless of what their RGB channels are
GColor8 color1 = GColorBlue;
color1.a = 0;
GColor8 color2 = GColorRed;
color2.a = 0;
cl_assert(gcolor_equal(color1, color2));
// But two colors with semi-transparent alpha... | (GColorBlackARGB8, gcolor_get_bw(GColorOrange).argb) | ;
}
static void prv_test_get_luminance(GColor8 color_to_test, GColor8Component expected_luminance) {
cl_assert_equal_i(gcolor_get_luminance(color_to_test), expected_luminance);
// Test that alpha doesn't affect luminance
GColor8 semitransparent_color = color_to_test;
semitransparent_color.a = 1;
cl_assert_eq... |
l_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r1_sw1_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 2);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin... | test_graphics_context_init(&ctx, fb) | ;
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
// AA = true, SW = 1
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 1);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bi... |
uting = true;
mutex_unlock(s_callback_list_semaphore);
reg_timer->cb(reg_timer->cb_data);
mutex_lock(s_callback_list_semaphore);
reg_timer->is_executing = false;
// Get the next one to execute before we possibly remove this one
iter = list_get_next(iter);
// Did the caller wa... | (&s_minutes_callbacks, prv_callback_registered_filter, &cb->list_node) | ) {
// better not be registered as a minute callback already
PBL_ASSERTN(!list_find(&s_seconds_callbacks, prv_callback_registered_filter, &cb->list_node));
cb->is_executing = false;
cb->pending_delete = false;
list_append(&s_minutes_callbacks, &cb->list_node);
} else {
// If it is marked for d... |
/*
* 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... | (af_config->gpio, af_config->gpio_pin_source, af_config->gpio_af) | ;
GPIO_Init(af_config->gpio, &init);
}
|
N_NUM_SAMPLES_FOR_HR_ZONE) {
// There wasn't enough data in the past minute to give us confidence that
// the new HR zone will represents that minute, default to Zone0
new_hr_zone = HRZone_Zone0;
}
bool new_hr_elevated = hr_util_is_elevated(hr_median);
// Before changing the zone make sure the user h... | for (size_t i = 0; i < ARRAY_LENGTH(s_hr_quality_weights_x100); i++) {
if (quality == s_hr_quality_weights_x100[i].quality) {
return s_hr_quality_weights_x100[i].weight_x100;
}
} | |
{
cl_assert_equal_p(gdraw_command_image_clone(NULL), NULL);
size_t size = sizeof(GDrawCommandImage) + (3 * sizeof(GDrawCommand)) +
(sizeof(GPoint) * 6);
GDrawCommandImage *image = malloc(size);
memset(image, 0, size);
GDrawCommandList *command_list = prv_create_command_list_3();
memcpy(&i... |
void test_gdraw_command__draw_image(void) {
GDrawCommandImage *image = malloc(sizeof(GDrawCommandImage) + sizeof(GDrawCommand) +
(sizeof(GPoint) * 2));
GDrawCommandList *command_list = &image->command_list;
*command_list = (GDrawCommandList) {
.num_commands = 1
};
GDrawCommand *command;
command ... | |
tatic GColor s_display_colors[NUM_SHAPES];
#define MAX_STROKE_WIDTH 20
static const GPathInfo s_triangle_path = {
3,
(GPoint[]) {
{ -10, 0 },
{ 0, 10 },
{ 10, 0 }
}
};
static const GPathInfo s_bucket_path = {
4,
(GPoint[]) {
{ -10, 0 },
{ -10, 30 },
{ 10, 30 },
{ 10, 0 }
}
};
... | {
AppData *data = app_state_get_user_data();
if (stroke_width_enabled(data->state_index)) {
data->stroke_width++;
if (data->stroke_width >= MAX_STROKE_WIDTH) {
data->stroke_width = 1;
}
}
log_state(data);
} |
static void select_handler(ClickRecognizerRef recognizer, void *context) {
AppData *data = app_state_get_user_data();
update_state(data, ((data->state_index + 1) % APP_STATE_NUM_STATES));
log_state(data);
}
static void down_handler(ClickRecognizerRef recognizer, void *context) {
AppData *data = app_state_ge... |
/*
* 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_get_root_layer(window) | |
ject_field(canvas, ROCKY_CANVAS_UNOBSTRUCTEDLEFT, unobstructed_left);
jerry_set_object_field(canvas, ROCKY_CANVAS_UNOBSTRUCTEDTOP, unobstructed_right);
jerry_set_object_field(canvas, ROCKY_CANVAS_UNOBSTRUCTEDWIDTH, unobstructed_width);
jerry_set_object_field(canvas, ROCKY_CANVAS_UNOBSTRUCTEDHEIGHT, unobstru... | if (!jerry_value_has_error_flag(error_value)) {
func(rocky_api_graphics_get_gcontext(), color);
} | ;
return jerry_create_undefined();
}
#define COLOR_BUFFER_LENGTH (12)
T_STATIC void prv_graphics_color_to_char_buffer(GColor8 color, char *buf_out) {
if (color.a <= 1) {
strncpy(buf_out, "transparent", COLOR_BUFFER_LENGTH);
} else {
snprintf(buf_out, COLOR_BUFFER_LENGTH, "#%02X%02X%02X",
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... | window_create() | ;
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
});
window_stack_push(window, true);
}
static void deinit(void) {
window_destroy(window);
}
int main(void) {
init();
app_event_loop();
deinit();
}
|
, {0, -40}, {40, 0}, {28, 0}, {28, 40}, {10, 40},
{10, 16}, {-10, 16}, {-10, 40}, {-28, 40}, {-28, 0},
},
};
static const GPathInfo s_bolt_path_info = {
.num_points = 6,
.points = (GPoint []) {{21, 0}, {14, 26}, {28, 26}, {7, 60}, {14, 34}, {0, 34}}
};
static const GPathInfo s_duplicates_path_info = {
6,
... | prv_reset() | ;
test_graphics_context_init(&ctx, fb);
s_current_path = s_house_path;
ctx.draw_state.clip_box = GRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 2);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
"gpath_filled_bottom_clipped.${BIT_DEPTH_NAME}.pbi"));
prv_reset();
test_gra... |
tate.current) {
// Word has been completely trimmed; init a new word
bool is_end_of_text = (word->end == NULL_CODEPOINT ||
char_iter_state.utf8_iter_state.current >= text_box_params->utf8_bounds->end);
if (!is_end_of_text) {
word_init(ctx, word, text_box_params, word->end);
}
return f... | {
return utf8_iter_state->current;
} | |
OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "clar.h"
#include "pebble_asserts.h"
#include "apps/system_app_ids.h"
#include "flash_region/flash_region.h"
#include "process_management/app_ins... | (st.st_size == pfs_write(fd, buf, st.st_size)) | ;
pfs_close(fd);
}
/* Start of test */
static const AppInstallId CRAZY_ID = 171717;
bool app_install_get_entry_for_uuid(const Uuid *uuid, AppInstallEntry *entry) {
AppInstallId id = app_install_get_id_for_uuid(uuid);
return app_install_get_entry_for_install_id(id, entry);
}
static bool prv_app_install_is_wa... |
tricType type, char *buffer, size_t buffer_size,
void *i18n_owner, void *sports_data) {
SportsData *data = sports_data;
switch (type) {
case WorkoutMetricType_Hr:
{
snprintf(buffer, buffer_size, "%d", data->current_bpm);
break;
}
case WorkoutMetricType_Sp... | (gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_workout_active__workout_render_walk_no_hrm(void) {
s_hrm_is_present = false;
s_workout_data = (WorkoutData) {
.steps = 567,
.duration_s = 84,
.distance_m = 1234,
.avg_pace = health_util_get_pace(84, 1234),
.bpm = 71,
.hr_zone = 0,
};
WorkoutActiveWindow *active_window = ... |
if (chunk_hdr.num_bytes + read_bytes > num_bytes) {
// Not enough room in buffer to read next chunk.
break;
}
if (!prv_pfs_read(logging_session->storage.fd, buffer, chunk_hdr.num_bytes)) {
last_whole_items_read_bytes = -1;
goto exit;
}
read... | (LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG,
"Consumed %d bytes from session %d", (int)consumed_bytes,
logging_session->comm.session_id) | |
/*
* 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(!error) | ;
}
void test_ancs_util__should_not_parse_malformed_notif_attr_dict(void) {
bool error = false;
cl_assert(!ancs_util_is_complete_notif_attr_response(s_chunked_dict_part_two, sizeof(s_chunked_dict_part_two),
&error));
cl_assert(error);
}
void test_ancs_util__should_extract_dict_from_buffer(void) {
stat... |
scaling animation
layer_set_clips(&pin_timeline_layout->icon_layer.layer, false);
layer_set_clips(&card_timeline_layout->icon_layer.layer, false);
// TODO: PBL-28738 Refactor kino reel transform APIs or usage of APIs
// There is a lot of shared code throughout, and the API is code space intensive
const bool... | layer_get_global_frame((Layer *)&card_timeline_layout->icon_layer, &icon_from) | ;
layer_get_global_frame((Layer *)&pin_timeline_layout->icon_layer, &icon_to);
// Unclip for the scaling animation
layer_set_clips(&pin_timeline_layout->icon_layer.layer, false);
layer_set_clips(&card_timeline_layout->icon_layer.layer, false);
const bool take_ownership = true;
KinoReel *new_reel = kino_ree... |
the reset pin on the MFi. Need to hold it low before powering the 2V5
// rail in order to get the MFi into a working state.
// In the future if the MFi becomes janky again we can use this to later pull the power.
gpio_use(BOARD_CONFIG.mfi_reset_pin.gpio);
GPIO_InitTypeDef gpio_cfg;
gpio_cfg.GPIO_OT... | prv_mon_config_unlock() | ;
return (uint16_t)millivolts;
}
bool pmic_set_charger_state(bool enable) {
// Defaults to ON
// LSB is enable bit
uint8_t register_value;
if (!prv_read_register(PmicRegisters_CHG_CNTL_A, ®ister_value)) {
return false;
}
if (enable) {
register_value |= 0x01;
} else {
register_value &= ~... |
mary.activity.update_threshold_steps;
// Determine the average for today
ActivityScalarStore total_steps_avg = prv_cur_step_avg(now_utc, minute_of_day);
const time_t pin_time_utc = time_util_get_midnight_of(now_utc) +
(s_activity_summary_settings.summary.activity.trigger_minute * SECONDS_PER_MINUTE);
... | {
activity_label = i18n_get("Walk", headings);
} | else {
activity_label = i18n_get("Workout", headings);
}
string_list_add_string(headings, headings_buf_size, activity_label, headings_buf_size);
string_list_add_string(values, values_buf_size, duration_str, values_buf_size);
}
static void prv_add_avg_pace_metric_info(StringList *headings, int headings_buf_s... |
/*
* 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... | (crc, (uint8_t*)&last_word, 4) | ;
}
return crc & 0xffffffff;
}
/*
* Data Logging Test App
*/
struct DataLoggingInfo {
TextLayer text_layer;
char text[32];
int counter;
uint32_t crc;
DataLoggingSessionRef logging_session;
uint8_t item_size;
};
static struct {
Window window;
struct DataLoggingInfo info[3];
TextLayer log_lay... |
{
prv_read_event_from_buffer_and_consume(&cb, &out_event[i]);
cl_assert_equal_b(memcmp(&event[i], &out_event[i], sizeof(PebbleHRMEvent)), false);
} |
}
}
#undef NUM_TEST_EVENTS
// Test the enable and disable functionality across subscriptions
void test_hrm_manager__enable_disable(void) {
// 1. Disabling and then enabling with no subscriber should leave the HRM off
hrm_manager_enable(false);
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_b(h... | |
/*
* 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... | progress_callback(sector - first_sector + 1, count, progress_context) | ;
}
}
FLASH_Lock();
return true;
}
bool system_flash_write(
uint32_t address, const void *data, size_t length,
SystemFlashProgressCb progress_callback, void *progress_context) {
dbgserial_print("system_flash_write(");
dbgserial_print_hex(address);
dbgserial_print(", ");
dbgserial_print_hex(le... |
/*
* 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_init(window, WINDOW_NAME("Morph Square Demo")) | ;
window_set_user_data(window, data);
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
.appear = prv_window_appear,
.unload = prv_window_unload,
});
window_set_click_config_provider_with_context(window, prv_click_config_provider, data);
const bool animated = true;
... |
sightResponseType type;
const char *text;
AttributeList attr_list;
} ResponseItem;
static void prv_set_open_app_action(AttributeList *action_attr_list, HealthCardType card_type,
void *i18n_owner) {
attribute_list_add_cstring(action_attr_list, AttributeIdTitle, i18n_get("Open A... | {
return PercentTier_BelowAverage;
} | else if (*percentage > config->insight_settings->summary.above_avg_threshold) {
return PercentTier_AboveAverage;
}
return PercentTier_OnAverage;
}
// ------------------------------------------------------------------------------------------------
// Generates a new timeline item for a summary pin
static NOIN... |
3);
cl_assert(list_count(&a) == 3);
cl_assert(list_count(&b) == 3);
cl_assert(list_count(&c) == 3);
cl_assert(list_count_to_tail_from(&a) == 3);
cl_assert(list_count_to_tail_from(&b) == 2);
cl_assert(list_count_to_tail_from(&c) == 1);
cl_assert(list_count_to_head_from(&c) == 3);
cl_assert(list_count_to... | cl_assert(list_find_prev(NULL, filter_odd, false, NULL) == NULL) | ;
}
void test_list__concatenate(void) {
ListNode a = LIST_NODE_NULL, b = LIST_NODE_NULL, c = LIST_NODE_NULL;
ListNode d = LIST_NODE_NULL, e = LIST_NODE_NULL, f = LIST_NODE_NULL;
cl_assert_equal_p(list_concatenate(&a, &b), &a);
cl_assert_equal_p(a.next, &b);
cl_assert_equal_p(b.prev, &a);
cl_assert_equal_... |
"stubs_gatt_client_subscriptions.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_prompt.h"
void gap_le_connect_bluetopia_connection_callback(uint32_t stack_id,
GAP_LE_Event_Data_t* event_data,
... | cl_assert(job) | ;
// Since there was nothing scheduled, expect that the ad data is set to the
// controller immediately:
cl_assert(gap_le_is_advertising_enabled());
// Check that the ad data that is passed to the controller is the same that
// was given when calling the API:
assert_ad_data(ad_data);
// Check that the ... |
#include "applib/fonts/fonts.h"
#include "applib/ui/app_window_stack.h"
#include "applib/ui/progress_window.h"
#include "applib/ui/ui.h"
#include "drivers/battery.h"
#include "kernel/pbl_malloc.h"
#include "process_management/app_install_manager.h"
#include "process_management/app_manager.h"
#include "process_managemen... | i18n_get("No internet\nconnection", data) | ;
#else
message = i18n_get("No internet connection", data);
#endif
break;
case AppFetchResultIncompatibleJSFailure:
// TODO: PBL-39752 make this a more expressive error message with a call to action
icon = TIMELINE_RESOURCE_GENERIC_WARNING;
message = i18n_get("Incompatible JS", data);
... |
imer_scheduled(s_app_data->timer[timer_idx_0], &expire_ms);
PBL_ASSERTN(scheduled && expire_ms <= 500);
PBL_LOG(LOG_LEVEL_DEBUG, "STT firing in %d ms", (int)expire_ms);
}
// =================================================================================
void two_timers_menu_cb(int index, void *ctx) {
uint32_t ... | PBL_ASSERTN(success) | ;
}
// =================================================================================
void invaid_timer_id_menu_cb(int index, void *ctx) {
void *cb_data = 0;
uint32_t zero_flags = 0;
menu_callback_prefix(index, ctx);
// invalid timer id
new_timer_start(0x12345678, 100, timer_callback, cb_data, zero_flag... |
EBUG("prv_assemble_packet, state:%d, bytes:%d", state->recv_state,
bytes_avail);
// Log message if we detected any receive errors
if (state->recv_error_count) {
PBL_LOG(LOG_LEVEL_ERROR, "%"PRIu32" receive errors detected", state->recv_error_count);
state->recv_error_count = 0;
}
while (!ex... | *protocol = state->hdr.protocol;
return state->msg_buffer;
} else {
return NULL;
}
} |
// ------------------------------------------------------------------------------------------
// Unit test support
// @return true if successful (buffer not full)
bool qemu_test_add_byte_from_isr(QemuSerialGlobals *state, uint8_t byte) {
return shared_circular_buffer_write(&state->isr_buffer, &byte, 1, false /*a... |
X);
const int key_len = strlen(key);
status_t s = settings_file_get(&file, key, key_len, value_out, sizeof(uint32_t));
prv_file_close_and_unlock(&file);
return (s == S_SUCCESS);
}
bool health_db_get_typical_step_averages(DayInWeek day, ActivityMetricAverages *averages) {
if (!averages) {
return false;
... | settings_file_delete(&file, key, key_len) | ;
prv_file_close_and_unlock(&file);
return rv;
}
status_t health_db_flush(void) {
mutex_lock(s_mutex);
status_t rv = pfs_remove(HEALTH_DB_FILE_NAME);
mutex_unlock(s_mutex);
return rv;
}
|
is_valid = false;
} else {
const size_t resource_size = kino_reel_get_data_size(reel);
if (resource_size == 0) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Cannot determine size for published icon");
is_valid = false;
} else if (resource_size > RESOURCE_MAX_SIZE) {
APP_LOG(APP_LOG_LEVEL_ERROR, ... | {
PBL_ASSERTN(timeline_res && res_info_out && (size < TimelineResourceSizeCount));
// Test the high bit to determine if system resource
// TODO PBL-24499: Remove check for system uuid - this is only in place to ease the migration
// from 3.4, where not all system pins use the correct id convention
if (timeli... | |
& 0x1) == 0) ||
((i > ((num_pages() * 7) / 10)) && (i < ((num_pages() * 8) / 10)))) {
cl_assert(pfs_remove(file_small) == S_SUCCESS);
}
}
// We limit this number because we would overflow our uint8_t.
const int num_regions = MIN(UINT8_MAX, (num_pages() * 5) / 10);
int fd = pfs_open("page_look... | cl_assert(rv == 0) | ;
rv = pfs_seek(fd, len + 1, FSeekCur);
cl_assert(rv == E_RANGE);
rv = pfs_seek(fd, len + 1, FSeekSet);
cl_assert(rv == E_RANGE);
rv = pfs_seek(fd, -1, FSeekSet);
cl_assert(rv == E_RANGE);
}
void test_pfs__read(void) {
const int rd_len = 10;
int rv = pfs_read(-1, NULL, rd_len);
cl_assert(rv == E_IN... |
l_seconds - 3 * deviate_seconds, total_seconds, &uuid);
if (activity_prefs_sleep_insights_are_enabled()) {
for (int i = 0; i < NUM_COPY_VARIANTS; i++) {
prv_push_sleep_summary_notification(now_utc, total_seconds + deviate_seconds,
total_seconds, i);
prv_push_s... | system_task_add_callback(prv_test_push_summary_pins, NULL) | ;
}
void activity_insights_test_push_rewards(void) {
system_task_add_callback(prv_test_push_rewards, NULL);
}
void activity_insights_test_push_day_insights(void) {
system_task_add_callback(prv_test_push_day_insights, NULL);
}
void activity_insights_test_push_walk_run_sessions(void) {
system_task_add_callback(p... |
/*
* 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 -0.0;
} | else {
half = -0.5;
}
} else {
half = 0.5;
}
return __builtin_floor(d + half);
}
|
/*
* 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... | attributes_actions_deep_copy(attr_list, &item_out->attr_list, action_group,
&item_out->action_group, item_out->allocated_buffer,
buf_end) | ;
if (!rv) {
timeline_item_free_allocated_buffer(item_out);
return false;
}
}
return true;
}
bool timeline_item_create_from_serial_data(TimelineItem *item,
uint8_t num_attributes, uint8_t num_actions, const uint8_t *data, size_t size,
size_t *string_alloc_size, uint8_t **string_buffer)... |
xisting result, create one:
if (!result) {
// Bound the number of items:
if (list_get_count() >= 10) {
list_free_last();
}
// Create new ScanResult:
result = (ScanResult *) malloc(sizeof(ScanResult));
if (!result) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Out of memory!");
return;
... | (&result->first_service_uuid, subtitle) | ;
} else {
// If advertisement did not contain Service UUIDs:
strncpy(subtitle, "No Service UUIDs", sizeof(subtitle));
}
menu_cell_basic_draw(ctx, cell_layer, title, subtitle, NULL);
}
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer,
MenuIndex... |
glyph = text_resources_get_glyph(&s_font_cache, 'c', &s_font_info);
glyph_size_bytes = glyph_get_size_bytes(glyph);
cl_assert_equal_m(c_glyph_data_bytes, glyph->data, glyph_size_bytes);
}
void test_text_resources__init_backup_font(void) {
// load the built in fallback font
uint32_t font_fallback = RESOURCE_I... | cl_assert(glyph != NULL) | ;
glyph_size_bytes = glyph_get_size_bytes(glyph);
cl_assert_equal_m(chinese_glyph_data_bytes, glyph->data, glyph_size_bytes);
glyph = text_resources_get_glyph(&s_font_cache, 0x8888 /* 袈 */, &s_font_info);
// the chinese pbpack does not contain the letter 袈, it should return the wildcard
cl_assert(glyph != NU... |
{ 1016, 216, 56},
{ 1080, 208, 16},
{ 944, 216, -112},
{ 896, 120, -136},
{ 1120, 64, -56},
{ 1152, 192, -96},
{ 1248, 256, -224},
{ 1520, 248, -224},
{ 1304, 248, -64},
// 24 seconds
{ 1016, 224, -80},
{ 984, 296, -112},
{ 1128, 360, -40},
{ 1296, 400, -24},
{ 12... | { 1464, 320, -216},
{ 1608, 392, -280},
{ 1088, 328, -56},
{ 848, 152, -88},
{ 1016, 248, -96},
{ 1200, 312, -96},
{ 1288, 424, -144},
{ 1088, 464, -136},
{ 1376, 496, -80},
{ 1424, 720, 0},
{ 936, 656, -176},
{ 1552, 584, -128},
{ 968, 616, -200},
{ 1256, 528, -8... |
{ 1136, 616, -80},
{ 1208, 528, -24},
{ 1368, 552, 24},
{ 1464, 448, 16},
{ 1312, 304, 48},
{ 1208, 80, 128},
{ 1216, 144, -16},
{ 1184, 192, -56},
{ 1048, 248, -16},
{ 1096, 200, 16},
{ 1112, 200, -32},
{ 856, 192, -136},
{ 1256, 120, -88},
{ 976, 136, -48},
... |
, true));
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 0, false));
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 0, true));
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 100, false));
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 100, true));
... | (app_smartstrap_attribute_begin_write(attr, &write_buffer, &write_length)) | ;
cl_assert(write_buffer == (uint8_t *)attr);
cl_assert(write_length == 100);
// end the write request
assert_result_ok(app_smartstrap_attribute_end_write(attr, 100, false));
// trigger the write request to be sent
stub_pebble_tasks_set_current(PebbleTask_KernelBackground);
cl_assert(smartstrap_attribut... |
r_dup == NULL);
// destroy the attribute
app_smartstrap_attribute_destroy(attr);
// destroy again (shouldn't do anything bad)
app_smartstrap_attribute_destroy(attr);
}
void test_app_smartstrap__read(void) {
// create the attribute
SmartstrapAttribute *attr = app_smartstrap_attribute_create(0x1111, 0x2222... | (attr, &write_buffer, &write_length) | );
cl_assert(write_buffer == (uint8_t *)attr);
cl_assert(write_length == 100);
// end the write request without sending anything
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 0, true));
// start the write request again
write_buffer = NULL;
write_length = 0;
assert_result_ok(app_smarts... |
//////////
static bool s_in_calendar_event = false;
static bool prv_get_calendar_ongoing(void) {
PebbleEvent event = fake_event_get_last();
if (event.type == PEBBLE_CALENDAR_EVENT) {
s_in_calendar_event = event.calendar.is_event_ongoing;
}
return s_in_calendar_event;
}
// Fake pins
///////////////////////... | (!prv_get_calendar_ongoing()) | ;
TimerID timer_id = stub_new_timer_get_next();
cl_assert_equal_i(timer_id, TIMER_INVALID_ID);
cl_assert(!stub_new_timer_is_scheduled(timer_id));
cl_assert(timeline_add(&item1));
timeline_event_handle_blobdb_event();
cl_assert_equal_i(fake_event_get_count(), 2);
cl_assert(!prv_get_calendar_ongoing());
... |
time(buf, buf_size, "%j", &good_data);
if (r == 0 || strncmp(buf, "125", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"j\": %s", buf);
}
r = strftime(buf, buf_size, "%m", &good_data);
if (r == 0 || strncmp(buf, "05", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"m\": %s", ... | {
const int buf_size = 64;
char buf[buf_size];
// Make sure the invalid structs don't crash us
// These should all return 0, but many don't seem to be doing that
strftime(buf, buf_size, "%a", &bad_data);
strftime(buf, buf_size, "%A", &bad_data);
strftime(buf, buf_size, "%b", &bad_data);
strftime(buf... |
// strftime(buf, buf_size, "%z", &bad_data);
// strftime(buf, buf_size, "%Z", &bad_data);
}
static void window_load(Window *window) {
prv_test_valid_data();
prv_test_invalid_data();
Layer *window_layer = window_get_root_layer(window);
result_layer = text_layer_create(GRect(0, 0, 144, 168));
text_laye... |
/*
* 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... | {
GBitmap bitmap = {0};
const GRect rect = EXPECTED_RECT_IN_PRE_FUNCTION;
// Passing NULL for the processor shouldn't cause any problems
graphics_draw_bitmap_in_rect_processed(&s_ctx, &bitmap, &rect, NULL);
// And it should try to draw the bitmap
cl_assert_equal_i(s_bitblt_bitmap_into_bitmap_tiled_calls.ca... |
#define EXPECTED_COMPOSITING_MODE_BEFORE_AND_AFTER_PRE_FUNCTION (GCompOpSet)
#define EXPECTED_TINT_COLOR_BEFORE_AND_AFTER_PRE_FUNCTION (GColorShockingPink)
#define COMPOSITING_MODE_TO_SPECIFY_IN_PRE_FUNCTION (GCompOpTint)
#define TINT_COLOR_TO_SPECIFY_IN_PRE_FUNCTION (GColorTiffanyBlue)
#define RECT_TO_SPECIFY_IN_PR... |
ite file!";
int rv;
int fd = pfs_open(file, OP_FLAG_WRITE, FILE_TYPE_STATIC, strlen(string));
cl_assert(fd >= 0);
rv = pfs_write(fd, (uint8_t *)string, strlen(string));
cl_assert_equal_i(rv, strlen(string));
int tmp_fd = pfs_open(file, OP_FLAG_OVERWRITE, FILE_TYPE_STATIC, strlen(overwrite_string));
cl_a... | cl_assert(fd[i] >= 0) | |
rink to min size, otherwise shrink from max to min
int16_t current_size = (overshoot != 0) ? overshoot + max : max;
shrink = prv_create_int16_prop_anim(current_size, min, stage_duration, &s_animated_dot_impl,
data);
if (!shrink) {
goto cleanup;
}
revert = prv_create_int16_prop_anim(min, max, stage... | (&data->mic_window.mic_dot_layer) | ;
data->mic_window.mic_dot_radius = MIC_DOT_MAX_RADIUS;
data->mic_window.mic_dot_anim = prv_create_pulse_dot_anim(data, MIN_RADIUS,
MIC_DOT_MAX_RADIUS, OVERSHOOT, DELAY_DURATION, ANIMATION_DURATION);
animation_schedule(data->mic_window.mic_dot_anim);
animation_set_elapsed(data->mic_window.mic_dot_anim, ... |
/*
* 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_flash_read_next_byte() | ;
} while (status_register & 0x1);
prv_flash_end_cmd();
}
static void prv_flash_write_page(const uint8_t* buffer, uint32_t start_addr, uint16_t buffer_size) {
// Ensure that we're not trying to write more data than a single page (256 bytes)
CD_ASSERTN(buffer_size <= FLASH_PAGE_SIZE);
CD_ASSERTN(buffer_size)... |
tailHeading) {
.primary_label = "LABEL1",
.primary_value = "value1",
.secondary_label = "LABEL2",
.secondary_value = "value2",
.fill_color = GColorWhite,
#if PBL_BW
.outline_color = GColorBlack,
#endif
},
.num_subtitles = 1,
.subtitles = &(HealthDetailSubtitle) {
.l... | prv_create_card_and_render(&config) | ;
#if PBL_ROUND
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 7), MenuRowAlignCenter, false);
#else
GPoint offset = scroll_layer_get_content_offset(&card->scroll_layer);
offset.y -= scroll_layer_get_content_size(&card->scroll_layer).h;
scroll_layer_set_content_offset(&card->scroll_layer, offse... |
ate.node->id, &all_day_item.header.id));
cl_assert(!state.node->all_day);
cl_assert_equal_i(state.node->timestamp, midnight_march_3_utc + SECONDS_PER_DAY);
cl_assert_equal_i(state.node->duration, 0);
cl_assert_equal_i(state.current_day, midnight_march_2_pst + SECONDS_PER_DAY);
// no more
cl_assert(!iter_ne... | (&head, &multiday_item.header.id) | );
cl_assert(timeline_iter_remove_node_with_id(&head, &multiday_item.header.id));
cl_assert(timeline_iter_remove_node_with_id(&head, &multiday_item.header.id));
cl_assert(timeline_iter_remove_node_with_id(&head, &multiday_item.header.id));
cl_assert(!timeline_iter_remove_node_with_id(&head, &multiday_item.heade... |
ew_index,
MenuIndex old_index,
void *callback_context) {
if (new_index->row == 1) {
new_index->row = 2;
}
if (new_index->row == 3) {
new_index->row = 4;
}
}
void test_menu_layer__center_focused_handles_skipped_rows(void) {
MenuLayer l;
m... | (&l, false, MenuRowAlignNone, true) | ;
// these values are unchanged until the animation updates them
cl_assert_equal_i(2, menu_layer_get_selected_index(&l).row);
cl_assert_equal_i(2 * basic_cell_height, l.selection.y);
cl_assert_equal_i(initial_scroll_offset - 2 * basic_cell_height,
l.scroll_layer.content_sublayer.bounds.origi... |
ending_notified = (PendingInfo) {
.active = true,
.attribute = attribute
};
}
static void prv_notified_handler(SmartstrapAttribute *attribute) {
cl_assert(s_pending_notified.active);
cl_assert(s_pending_notified.attribute == attribute);
s_pending_notified.active = false;
}
// Setup
void test_app_sma... | (app_smartstrap_attribute_read(attr)) | |
neItem *item) {
for (int i = 0; i < item->action_group.num_actions; i++) {
TimelineItemAction *action = &item->action_group.actions[i];
if (prv_should_show_action_in_action_menu(data, item, action)) {
return true;
}
}
return false;
}
static WindowStack *prv_get_window_stack(void) {
if (pebble... | prv_mute_notification(action_menu_item, MuteBitfield_Always) | ;
}
static void prv_mute_notification_weekdays(ActionMenu *action_menu,
const ActionMenuItem *action_menu_item,
void *context) {
prv_mute_notification(action_menu_item, MuteBitfield_Weekdays);
}
static void prv_mute_notification_w... |
= kernel_malloc(sizeof(ButtonPressNewTimerContext));
if (!new_timer_context) {
goto error;
}
*new_timer_context = (ButtonPressNewTimerContext) {
.button_id = button_id,
.button_is_held_down = false,
.num_presses_remaining = num_presses,
.hold_down_time_ms = hold_down_timeout_ms,
.delay_be... | (generation, prv_serial_dump_chunk_callback,
prv_serial_dump_completed_callback) | ;
prompt_command_continues_after_returning();
}
static void spam_callback(void *data) {
uint32_t iteration = (uintptr_t) data;
uint8_t buffer[128];
time_t base = sys_get_time();
for (int i = 0; i < 16; ++i) {
LogBinaryMessage* msg = (LogBinaryMessage*) buffer;
msg->timestamp = htonl(base + iteration ... |
_data);
}
void analytics_external_collect_ble_pairing_info(void) {
unsigned int ble_pairings_count = prv_get_num_pairings_by_type(BtPersistBondingTypeBLE);
analytics_set(ANALYTICS_DEVICE_METRIC_BLE_PAIRING_RECORDS_COUNT,
ble_pairings_count, AnalyticsClient_System);
analytics_set(ANALYTICS_DEVIC... | if (link_key) {
new_data.bt_classic_data.link_key = *link_key;
} |
if (platform_bits) {
new_data.bt_classic_data.platform_bits = *platform_bits;
}
GapBondingFileSetStatus status =
prv_file_set(&key, sizeof(key), &new_data, sizeof(new_data));
if (status == GapBondingFileSetFail) {
return BT_BONDING_ID_INVALID;
}
if (status == GapBondingFileSetUpdated) {
... |
s_ad_data, &tx_power_level_out));
}
void test_ble_ad_parse__128_bit_uuid(void) {
// AD Element, Length: 2, AD Type: Flags
// AD Element, Length: 17, AD Type: More 128-bit UUIDs available,
// Value: 0x68753a444d6f12269c600050e4c00067
uint8_t data[GAP_LE_AD_REPORT_DATA_MAX_LENGTH] =
"\x02\x01\x1a\x11\x06\x6... | ble_ad_set_service_uuids(ad, uuid, 8) | |
/*
* 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... | custom_reel->impl->get_gbitmap_sequence(reel) | |
PBL_ASSERTN(pos) | ;
// Reset all state when a touchdown event occurs
prv_touch_context_reset(ctx);
ctx->start_pos = *pos;
ctx->start_time_ms = time_ms;
ctx->start_pressure = pressure;
prv_touch_queue_add(ctx, touch_idx, TouchEvent_Touchdown, pos, pressure, time_ms);
TOUCH_DEBUG("Touch %"PRIu8":... | |
*major, unsigned int *minor,
const char **patch_ptr) {
*major = GIT_TAG_V_MAJOR;
*minor = GIT_TAG_V_MINOR;
*patch_ptr = GIT_TAG_V_PATCH;
}
// ---------------------------------------------------------------------------------------------
// The transport callback we pass to proto... | (&s_parsed_msg.msrmt.uuid, uuid_str) | ;
LOG(" Uuid: %s", uuid_str);
LOG(" time_utc: %"PRIu32", time_end_utc: %"PRIu32", utc_to_local: %"PRIi32"",
s_parsed_msg.msrmt.time_utc, s_parsed_msg.msrmt.time_end_utc,
s_parsed_msg.msrmt.utc_to_local);
LOG(" %"PRIu32" types: ", s_parsed_msg.msrmt.num_types);
for (unsigned i = 0; i <... |
ter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
// check sixth
cl_assert(!iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id));
cl_assert(uuid_equal(&state.node->id, &s_items[3].header.id));
cl_assert(state.node);
cl_assert(it... | iter_next(&iterator) | );
// 1 delete
cl_assert(timeline_iter_remove_node_with_id(&head, &all_day_item.header.id));
cl_assert(!timeline_iter_remove_node_with_id(&head, &all_day_item.header.id));
}
void test_timeline__24h_non_all_day_starting_mid_day(void) {
const time_t midnight_march_3_utc = 1425340800;
TimelineItem all_day_item... |
? 1 : 0;
minute_data[i].heart_rate_bpm = next_heart_rate_bpm++;
minute_data[i].heart_rate_total_weight_x100 = next_heart_rate_heart_rate_total_weight_x100++;
minute_data[i].heart_rate_zone = next_heart_rate_zone++;
}
}
// ----------------------------------------------------------------... | (&s_dls_records[j].samples[i],
&minute_data[(j * ALG_MINUTES_PER_DLS_RECORD) + i],
sizeof(minute_data[i])) | ;
}
}
}
// ------------------------------------------------------------------------------------
static void prv_assert_minute_data(HealthMinuteData *actual, AlgMinuteDLSSample *expected) {
cl_assert_equal_i(actual->steps, expected->base.steps);
cl_assert_equal_i(actual->orientation, expected->base.orientati... |
nt.data.heart_rate_update.quality, HRMQuality_OffWrist);
// Should fire off an event. Good HR and Good Quality
prv_advance_time_hr(1 /*sec*/, 120 /*hr*/, HRMQuality_Excellent, true /*force_continuous*/);
cl_assert_equal_i(s_num_hr_events, 4);
cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.current_bpm... | (ActivityMetricSleepEnterAtSeconds, 1, metric_values) | ;
cl_assert_equal_i(metric_values[0], 60);
activity_metrics_prv_set_metric(ActivityMetricSleepExitAtSeconds, Wednesday, 60);
activity_get_metric(ActivityMetricSleepExitAtSeconds, 2, metric_values);
cl_assert_equal_i(metric_values[1], 60);
activity_stop_tracking();
fake_system_task_callbacks_invoke_pending... |
--------------------------------------------------------------
static void prv_health_event_handler(HealthEventType event,
void *context) {
HealthAPITestAppData *data = (HealthAPITestAppData *)context;
if (event == HealthEventMovementUpdate) {
// Test the peek function
... | (DELTA_STEP_RECT) | ;
text_layer_set_text_alignment(data->steps_card.delta_step_layer, GTextAlignmentCenter);
text_layer_set_font(data->steps_card.delta_step_layer,
fonts_get_system_font(FONT_KEY_LECO_38_BOLD_NUMBERS));
text_layer_set_background_color(data->steps_card.delta_step_layer, GColorClear);
text_laye... |
/*
* 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... | health_hr_summary_card_get_bg_color(card_layer) | |
_XY GRect(6, 6, RECT_WIDTH, RECT_HEIGHT)
#define OFFSET_DRAW_RECT_CLIP_NXNY GRect(-16, -16, RECT_WIDTH, RECT_HEIGHT)
void test_graphics_draw_round_rect_${BIT_DEPTH_NAME}__offset_aa_sw(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if... | graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_aa_sw4_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_XY, OFFSET_RECT_CLIP_XY, true, 4);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_REC... |
// AA = true, SW = 11
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, true, 11);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
cl_check(gbitmap_pbi_eq(&ctx.dest_bi... |
/*
* 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 (usb_is_connected) {
next_state = RuninStateRunning;
} |
break;
case RuninStateRunning:
if (!data->countdown_running) {
data->countdown_running = true;
}
if (!usb_is_connected) {
data->pass_count = 0;
next_state = RuninStatePlugCharger;
break;
}
if (charge_percent > SLOW_THRESHOLD_PERCENTAGE && data->fa... |
/*
* 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 ((handler_offset == ClickHandlerOffsetRawUp || handler_offset == ClickHandlerOffsetRawDown) &&
recognizer->config.raw.context != NULL) {
// The context for raw click events is overridable:
context = recognizer->config.raw.context;
} else {
context = recognizer->config.context;... |
handler(recognizer, context);
}
if (needs_reset) {
prv_click_reset(recognizer);
}
return true;
} else {
return false;
}
}
inline static bool prv_is_hold_to_repeat_enabled(ClickRecognizer *recognizer) {
return (recognizer->config.click.repeat_interval_ms >= 30);
}
inline stati... |
e(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,
.type = TimelineItemTypeNotification,
.stat... | (notification_storage_get(&i2, &r), false) | ;
notification_storage_store(&e3);
cl_assert(notification_storage_get(&i1, &r));
compare_notifications(&e1, &r);
free(r.allocated_buffer);
cl_assert_equal_b(notification_storage_get(&i2, &r), false);
cl_assert(notification_storage_get(&i3, &r));
compare_notifications(&e3, &r);
free(r.allocated_buffe... |
/*
* 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 (gcolor_equal(bg_color, GColorBlack)) {
text_layer_set_background_color(text, GColorWhite);
text_layer_set_text_color(text, GColorBlack);
} else {
text_layer_set_background_color(text, GColorBlack);
text_layer_set_text_color(text, GColorWhite);
} |
}
static void raw_click_handler(ClickRecognizerRef recognizer, Window *window, const bool up) {
ClickAppData *data = window_get_user_data(window);
sniprintf(data->text_buffer, TEXT_BUFFER_SIZE, up ? "Raw UP" : "Raw DOWN");
if (up) { // PBL_LOG requires a fixed const string, so can't use ternary
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... | (from_reel) | |
ld World firmware base");
erase_length += FW_WORLD_DIFFERENCE;
}
return system_flash_erase(system_flash_base, erase_length, prv_display_erase_progress, 0);
}
// Fills in the last 50% of the progress bar
static void prv_display_write_progress(
uint32_t progress, uint32_t total, void *ctx) {
display_firmw... | (BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS) | ) {
dbgserial_putstr("Our previous firmware update failed, aborting update.");
// Pretend like the new firmware bit wasn't set afterall. We'll just run the
// previous code, whether that was normal firmware or the recovery firmware.
boot_bit_clear(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS);
boot_bit_clear... |
///////////////////////////////////////////////////
void test_list__initialize(void) {
}
void test_list__cleanup(void) {
}
void test_list__insert_after(void) {
ListNode *tail = NULL;
ListNode a = LIST_NODE_NULL, b = LIST_NODE_NULL;
tail = list_insert_after(tail, &a);
cl_assert(tail == &a);
tail = list_inse... | (head == &bar3.list_node) | ;
cl_assert(list_get_next(head) == &bar2.list_node);
cl_assert(list_get_tail(head) == &bar1.list_node);
}
static bool is_odd(IntNode *node, void *data) {
return (node->value & 1);
(void)data;
}
static bool is_even(IntNode *node, void *data) {
return ((node->value & 1) == 0);
(void)data;
}
void test_list_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.