prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
eive_entity_update(nan_playback_info_update, sizeof(nan_playback_info_update));
prv_assert_initial_playback_state();
}
void test_ams__receive_incomplete_csv_list_player_playback_info_update(void) {
prv_connect_ams();
// Receive: playing, 200% playback rate
// 0000 00 01 00 31 2c 32 2e 30 ...1,2.0
uint8... | ams_destroy() | ;
// No assert hit.
}
void test_ams__destroy_disconnects_from_music_service(void) {
prv_discover_ams(1 /* num_instances */);
// Simulate successful subscription:
BLECharacteristic entity_update = s_characteristics[0][AMSCharacteristicEntityUpdate];
ams_handle_subscribe(entity_update, BLESubscriptionNotifica... |
_update_handler_calls, b), 0);
// A should start out low
distance = prv_last_update_distance(a);
cl_assert(distance < TEST_ANIMATION_NORMALIZED_LOW);
// Execute to the start of B
prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(... | prv_count_handler_entries(&s_started_handler_calls, NULL) | , 3);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, NULL), 1);
// Execute to the end of B & C
prv_advance_to_ms_with_timers(start_ms + duration_total + 1 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, NULL), 3);
cl_assert_equal_i(prv_co... |
NULL,
false /* requires_address_pinning */,
false /* auto_accept_re_pairing */);
cl_assert(id_2 != BT_BONDING_ID_INVALID);
cl_assert_equal_i(s_ble_bonding_change_add_c... | cl_assert_equal_m(&irk_out, &pairing_3.irk, sizeof(irk_out));
cl_assert_equal_m(&device_out, &pairing_3.identity, sizeof(device_out));
bt_persistent_storage_register_existing_ble_bondings();
cl_assert_equal_b(bonding_sync_contains_pairing_info(&pairing_1, true), true);
cl_assert_equal_b(bonding_sync_contains... |
void test_bluetooth_persistent_storage__get_ble_by_addr(void) {
bool ret;
// Output variables
SMIdentityResolvingKey irk_out;
// Store a pairing
SMPairingInfo pairing = (SMPairingInfo) {
.irk = (SMIdentityResolvingKey) {
.data = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
... |
bottom_right_point =
GPoint(grect_get_max_x(&s_ctx.dest_bitmap.bounds),
grect_get_max_y(&s_ctx.dest_bitmap.bounds));
GPoint offset_point = gpoint_sub(framebuffer_bottom_right_point,
GPoint(bitmap->bounds.size.w, bitmap->bounds.size.h));
offset_point = gpoi... | {
prv_offset_bitmap_layer_test(GPoint(-25, 0));
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
} |
void test_graphics_draw_bitmap__offset_bitmap_layer_across_y(void) {
prv_offset_bitmap_layer_test(GPoint(0, 75));
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_bitmap__offset_bitmap_layer_across_ny(void) {
prv_offset_bitmap_layer_test(GPoint(0, -25));
cl_check(gbitmap... |
/*
* 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... | PBL_LOG(LOG_LEVEL_WARNING, "Got pairing response, but disconnected in the mean time.") | ;
return;
}
uint16_t conn_idx = connection_get_idx(connection);
pair_reply(conn_idx, response->is_confirmed);
}
void hc_endpoint_pairing_handler(const HcProtocolMessage *msg) {
switch (msg->command_id) {
case HcMessageID_Pairing_PairingResponse:
prv_handle_pairing_response((const HcProtocolMessa... |
/*
* 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(default_only_define()) | |
-80},
{ 928, 440, -104},
{ 1160, 400, -80},
// 110 seconds
{ 1328, 400, -16},
{ 1440, 304, 160},
{ 1648, 472, 16},
{ 1232, 472, 8},
{ 1248, 288, 88},
{ 1328, 280, 112},
{ 1248, 312, 136},
{ 952, 160, 152},
{ 800, 240, 96},
{ 776, 232, 104},
{ 752, 176, 136},
... | ARRAY_LENGTH(samples) | ;
return samples;
}
// ----------------------------------------------------------------
// Sample captured: 2015-10-05 15:59:26 local
AccelRawData *activity_sample_walk_200_pbl_25661_9(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_200_pbl_25661_9
//> TEST... |
/*
* 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... | ams_handle_service_discovered(&s_characteristics[i][0]) | |
ingsFile file = {{0}};
if (settings_file_open(&file, SHELL_PREFS_FILE_NAME, SHELL_PREFS_FILE_LEN) != S_SUCCESS) {
return;
}
prv_convert_deprecated_backlight_behaviour_key(&file);
// Init state for each pref from our backing store
uint32_t num_entries = ARRAY_LENGTH(s_prefs_table);
const PrefsTableEntr... | prv_prefs_entry(key, key_len) | ;
if (!entry) {
return 0;
}
return entry->value_len;
}
// ------------------------------------------------------------------------------------
// Exported function used by blob_db API to read our backing store
bool prefs_private_read_backing(const uint8_t *key, size_t key_len, void *value, int value_len) {
... |
aw_vert_dotted_line_odd_offset_odd_cols_no_clip")));
// Test to make sure drawing on all cols creates checkerboard pattern
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_ODD, OFFSET_RECT_ODD, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NU... | (&ctx, GPoint(67, 96), 5) | ;
// T facing left - even vert, even horiz
graphics_draw_vertical_line_dotted(&ctx, GPoint(100, 90), 10);
graphics_draw_horizontal_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_dott... |
fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
layer_add_child(&window->layer, &msg_text_layer->layer);
msg_text_layer = &data->msg_text_layer[2];
text_layer_init(msg_text_layer, &GRect(0, 64, window->layer.bounds.size.w, 40));
if (data->test_case >= FLASH_TEST_CASE_RUN_SWITCH_MODE_ASYNC) {
text_layer_s... | (test_window, data) | ;
window_set_click_config_provider(test_window, click_config_provider);
const bool animated = true;
app_window_stack_push(test_window, animated);
}
static void flash_test_window_load(Window *window) {
struct FlashTestData *data = (struct FlashTestData*) window_get_user_data(window);
// Configure menu items... |
ed_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), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_sta... | (prv_count_handler_entries(&s_update_handler_calls, b), 0) | ;
// A should start out low
distance = prv_last_update_distance(a);
cl_assert(distance < TEST_ANIMATION_NORMALIZED_LOW);
// Execute to the start of B
prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a),... |
DictionaryIterator* new_iter,
const bool update_existing_keys_only,
const DictionaryKeyUpdatedCallback update_key_callback,
void* context) {
DictionaryResult result = DI... | task_free(orig_buffer) | ;
return result;
}
Tuple *dict_find(const DictionaryIterator *iter, const uint32_t key) {
DictionaryIterator iter_copy = *iter;
Tuple *tuple = dict_read_first(&iter_copy);
while (tuple) {
if (tuple->key == key) {
return tuple;
}
tuple = dict_read_next(&iter_copy);
}
return NULL;
}
|
if (with_fulltime) {
time_fmt = i18n_noop("%b %e, %l:%M %p");
} else {
time_fmt = i18n_noop("%B %e");
}
break;
case FullStyleLower24h:
case FullStyleCapital24h:
if (with_fulltime) {
time_fmt = i18n_noop("%b %e, %R");
} else {
... | (buffer, buf_size, i18n_noop("%d"), timestamp) | |
/*
* 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... | (LOG_LEVEL_DEBUG, evt->value, evt->length) | ;
Connection *connection = connection_by_idx(evt->conn_idx);
if (!connection) {
PBL_LOG(LOG_LEVEL_WARNING, "Read_device_name: Failed to find connection");
return;
}
typedef struct PACKED HcProtocol_GapDeviceNameResponse {
HcProtocol_GapDeviceNameResponseHeader header;
uint8_t name[evt->length];... |
(BusFault_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY) | ;
NVIC_SetPriority(UsageFault_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY);
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
SCB->SHCSR |= SCB_SHCSR_BUSFAULTENA_Msk;
SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk;
}
typedef struct CrashInfo {
PebbleTask task;
Uuid app_uuid;
uint8_t build_id[BUILD_ID_EXPECTED_LEN];
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... | (s_cache, prv_destructor) | ;
}
void ancs_app_name_storage_deinit(void) {
if (s_cache) {
circular_cache_flush(s_cache);
kernel_free(s_cache->cache);
kernel_free(s_cache);
s_cache = NULL;
}
}
void ancs_app_name_storage_store(const ANCSAttribute *app_id, const ANCSAttribute *app_name) {
if (!app_id || !app_name) {
retur... |
on = 0,
.type = TimelineItemTypePin,
.layout = LayoutIdTest,
// don't care about the rest
}
};
static TimelineItem item2 = {
.header = {
.id = {0x55, 0xcb, 0x7c, 0x75, 0x8a, 0x35, 0x44, 0x87,
0x90, 0xa4, 0x91, 0x3f, 0x1f, 0xa6, 0x76, 0x01},
.parent_id = {0xff, 0xf6, 0x21, 0x5b, 0xc... | cl_must_pass(pin_db_set_status_bits(&item1.header.id, TimelineItemStatusDismissed)) | ;
cl_must_pass(pin_db_read_item_header(&item, &item1.header.id));
cl_assert_equal_i(item.header.status, TimelineItemStatusDismissed);
}
|
/*
* 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 (!addr) {
return true;
}
BTDeviceAddress invalid = {};
return bt_device_address_equal(addr, &invalid);
} | |
aw_text;
void graphics_draw_text(GContext *ctx, const char *text, GFont const font, const GRect box,
const GTextOverflowMode overflow_mode, const GTextAlignment alignment,
GTextAttributes *text_attributes) {
record_mock_call(s_graphics_draw_text){
.draw_text.box = b... | cl_assert_equal_i(1, s_layer_mark_dirty.call_count) | ;
cl_assert_equal_p(&s_app_window_stack_get_top_window.layer, s_layer_mark_dirty.last_call.layer);
}
void test_rocky_api_graphics__provides_draw_event(void) {
rocky_global_init(s_graphics_api);
cl_assert_equal_b(false, rocky_global_has_event_handlers("draw"));
EXECUTE_SCRIPT("_rocky.on('draw', function() {});... |
/*
* 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_pbl_log_level_from_jerry_log_level(level) | ;
if (log_level > LOG_LEVEL_DEBUG) {
return;
}
va_list args;
va_start(args, format);
app_log_vargs(log_level, "JERRY-LOG", 0, format, args);
va_end(args);
}
/**
* Provide console message implementation for the engine.
*/
void jerry_port_console(const char *format, ...) {
if (format[0] == '\n' && s... |
of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the sp... | utf8_get_bounds(&success, "In\n\n\nN\nout") | |
/*
* 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... | {
dictation_session_destroy(session);
} | |
_buffer("Today", buffer, buffer_size);
} else {
i18n_get_with_buffer("All day", buffer, buffer_size);
}
}
static void prv_copy_relative_time_string(char *number_buffer, uint8_t number_buffer_size,
char *word_buffer, uint8_t word_buffer_size, time_t timestamp, time_t end_time) {
time_t now = rtc_get_time(... | prompt_send_response_fmt(buffer, 80, "Time is now <%s>", rtc_get_time_string(time_buffer)) | ;
}
void command_set_time(const char *arg) {
time_t t = atoi(arg);
if (t == 0) {
prompt_send_response("Invalid length");
return;
}
prv_update_time_info_and_generate_event(&t, NULL);
char buffer[80];
char time_buffer[26];
prompt_send_response_fmt(buffer, 80, "Time is now <%s>", rtc_get_time_stri... |
/*
* 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... | (&bitmap, 0, 0) | );
// Fix it up again
s_fake_bitmap_data.row_size_bytes = 8;
cl_assert(gbitmap_init_with_resource_system(&bitmap, 0, 0));
// But now change the palette format to something that requires more space and watch it fail
s_fake_bitmap_data.info.format = GBitmapFormat4BitPalette;
cl_assert(!gbitmap_init_with_res... |
because the right flip animation is actually
// played backwards
compositor_round_flip_transitions_flip_animation_update(ctx, ANIMATION_NORMALIZED_MAX,
CompositorTransitionDirectionRight,
GColorWhite... | prv_gbitmap_get_data_row_info(bitmap, y) | ;
for (int x = 0; x < DISP_COLS; x++) {
GColor8 color = GColorFromRGB(1 * x * UINT8_MAX / DISP_COLS,
2 * x * UINT8_MAX / DISP_COLS,
4 * x * UINT8_MAX / DISP_COLS);
if (row_info.min_x <= x && x <= row_info.max_x) {
row_info.d... |
ask_value = 5;
static const int16_t num_mask_values = 4;
static const int16_t num_src_colors = 256; // 8-bit color
static const int16_t num_dest_colors = 64; // Framebuffer ignores alpha, so only 6-bit color
static void prv_prepare_canvas(GContext *ctx, GSize desired_size) {
s_dest_bitmap = gbitmap_create_blank(desi... | (graphics_context_mask_record(ctx, mask)) | ;
for (int16_t x = 0; x < num_src_colors; x++) {
GColor src_color = (GColor) { .argb = (uint8_t)x };
for (int mask_value_index = 0; mask_value_index < num_mask_values; mask_value_index++) {
int16_t y1 = (int16_t)(mask_value_index * num_pixels_per_mask_value);
int16_t y2 = (int16_t)(y1 + num_pixel... |
/*
* 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... | PBL_LOG(LOG_LEVEL_DEBUG, ">> Flash operation time!") | ;
PBL_LOG(LOG_LEVEL_DEBUG, ">> Flash operation time!");
PBL_LOG(LOG_LEVEL_DEBUG, ">> Flash operation time!");
PBL_LOG(LOG_LEVEL_DEBUG, ">> Flash operation time!");
PBL_LOG(LOG_LEVEL_DEBUG, ">> Erasing 0x%x", BASE_ADDRESS);
flash_erase_sector_blocking(BASE_ADDRESS);
PBL_LOG(LOG_LEVEL_DEBUG, ">> Erasing 0x%x... |
// we have a little room between the top of notification and top of frame
dy = offset;
} else {
// so much roooooooooom, scroll up normal amount
dy = (is_repeating) ? REPEATING_SCROLL_PX : SCROLL_PX;
}
break;
}
case ScrollDirectionDown:
{
#if PBL_RECT
... | (recognizer) | , is_repeating);
}
}
static void prv_swap_layer_click_config_provider(void *context) {
// Use raw clicks to avoid single click delay which results from having multi-click enabled
window_raw_click_subscribe(BUTTON_ID_UP, prv_raw_click_handler, NULL, context);
window_single_repeating_click_subscribe(BUTTON_ID_UP... |
/*
* 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... | assert_app_file_name_make(7, "app_app") | ;
}
void test_app_file__name_make_hex_1(void) {
assert_app_file_name_make(0x5abc, "woop");
}
void test_app_file__name_make_hex_2(void) {
assert_app_file_name_make(0x12345, "looks_like_decimal");
}
void test_app_file__name_make_negative(void) {
assert_app_file_name_make(-42, "builtin_app");
}
void test_app_fil... |
= true;
gpio_output_set(&slave->spi_scs, true); // SCS asserted (low)
}
void spi_ll_slave_scs_deassert(const SPISlavePort *slave) {
PBL_ASSERTN(slave->slave_state->initialized);
PBL_ASSERTN(slave->slave_state->acquired);
PBL_ASSERTN(slave->slave_state->scs_selected);
slave->slave_state->scs_selected = false... | {
PBL_ASSERTN(slave->rx_dma);
PBL_ASSERTN(slave->slave_state->initialized);
PBL_ASSERTN(slave->slave_state->acquired);
PBL_ASSERTN(slave->slave_state->dma_state == SPISlavePortDMAState_Idle);
slave->slave_state->dma_state = SPISlavePortDMAState_Read;
slave->slave_state->dma_complete_handler = handler;
sla... |
void spi_ll_slave_read_dma_stop(const SPISlavePort *slave) {
if (slave->slave_state->dma_state != SPISlavePortDMAState_Read) {
return;
}
dma_request_stop(slave->rx_dma);
PBL_ASSERTN(slave->slave_state->initialized);
PBL_ASSERTN(slave->slave_state->acquired);
prv_spi_dma_cmd(slave->spi_bus, SpiI2sDma_R... |
ion for the kernel receiver, execute the endpoint handler on KernelBG.
const PebbleTask g_default_kernel_receiver_opt_bg = PebbleTask_KernelBackground;
//! If the endpoint handler puts events onto the KernelMain queue *and* it is important that
//! PEBBLE_COMM_SESSION_EVENT and your endpoint's events are handled in or... | system_task_add_callback(prv_default_kernel_receiver_cb, receiver) | ;
}
}
static void prv_default_kernel_receiver_cleanup(Receiver *receiver) {
DefaultReceiverImpl *impl = (DefaultReceiverImpl *)receiver;
if (impl->handler_scheduled) {
return; // the kernel BG/main callback will free the data
}
prv_wipe_receiver_data(impl);
kernel_free(impl);
}
const ReceiverImplement... |
Context ctx;
test_graphics_context_init(&ctx, fb);
// Letter C
uint32_t angle_end = TRIG_MAX_ANGLE + (TRIG_MAX_ANGLE / 8);
uint32_t angle_start = (TRIG_MAX_ANGLE / 8) * 3;
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_context_set_fill_color(&ctx, GColorRed);
grap... | TO_TRIG(370) | ), ((EllipsisDrawConfig){
.start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(0),GCornerTopRight},
.full_quadrants = GCornerNone,
.end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(10),GCornerTopRight}
}));
// # Section with quadrant filling
// Tests for full quadrants
cl_assert_equal_edc(prv_calc_dra... |
_equal(&state.pin.header.id, &s_all_day_items[0].header.id));
cl_assert(state.node->all_day);
cl_assert(!iter_next(&iterator));
cl_assert(iter_prev(&iterator));
cl_assert(!iter_prev(&iterator));
}
void test_timeline__all_day_middle_past(void) {
prv_insert_all_day_items();
// 1421183640 is 13:14 on Jan 13... | iter_next(&iterator) | );
#endif
cl_assert(uuid_equal(&state.pin.header.id, &s_extra_case_items[0].header.id));
cl_assert(!iter_next(&iterator));
}
// 11 am, all events passed
void test_timeline__extra_case_backwards(void) {
prv_insert_extra_case_items();
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *he... |
er_compiled_with_legacy2_sdk()) {
bitmap->info.version = GBITMAP_VERSION_0;
}
bitmap->info.version = GBITMAP_VERSION_CURRENT;
}
uint8_t gbitmap_get_version(const GBitmap *bitmap) {
if (process_manager_compiled_with_legacy2_sdk()) {
return GBITMAP_VERSION_0;
}
return bitmap->info.version;
}
// indire... | grect_clip(&sub_rect, &base_bitmap->bounds) | ;
sub_bitmap->bounds = sub_rect;
}
GBitmap* gbitmap_create_as_sub_bitmap(const GBitmap *base_bitmap, GRect sub_rect) {
GBitmap *bitmap = prv_allocate_gbitmap();
if (bitmap) {
gbitmap_init_as_sub_bitmap(bitmap, base_bitmap, sub_rect);
}
return bitmap;
}
static GColor* prv_allocate_palette(GBitmapFormat f... |
/*
* 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... | (&launcher_event) | |
ame watchface crashes twice in one minute, then we show a dialog informing
// the user that the watchface has crashed. Any button press will dismiss
// the dialog and show us the default system watch face.
PBL_ASSERTN(install_id != INSTALL_ID_INVALID);
if (crash_info.install_id != install_id ||
(crash_in... | launcher_cancel_force_quit() | ;
// Make sure the process is safe to kill. If this method returns false, it will have set a timer to post
// another KILL event in a few seconds, thus giving the process a chance to clean up.
if (!process_manager_make_process_safe_to_kill(PebbleTask_App, gracefully)) {
// Maybe next time...
return fals... |
/*
* 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... | shared_circular_buffer_get_read_space_remaining(&state->isr_buffer,
&state->isr_buffer_client) | |
ntf(hr_str, hr_buf_size, i18n_get("%d Min", headings), zone_1_minutes);
string_list_add_string(headings, headings_buf_size,
i18n_get("Fat Burn", headings), headings_buf_size);
string_list_add_string(values, values_buf_size, hr_str, values_buf_size);
}
const int zone_2_mi... | {
// Unsupported activity type
goto cleanup;
} |
const NotificationConfig config = {
.notif_time = notif_time,
.insight_type = type,
.icon_id = icon,
.body = body,
.headings = headings,
.values = values,
.open_app = {
.enabled = true,
.health_card_type = HealthCardType_Activity,
},
};
analytics_event_health_insigh... |
/*
* 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... | (ctx, GPoint(p0.x, p0.y)) | ;
}
err -= dy;
if (err < 0) {
p0.y += ystep;
err += dx;
}
}
}
#if PBL_COLOR
MOCKABLE void graphics_line_draw_1px_aa(GContext* ctx, GPoint p0, GPoint p1) {
// Implementation of Wu-Xiang fast anti-aliased line drawing algorithm
// Points over which we're going to iterate adjusted to dr... |
he stopped handler
void test_animation__reschedule_from_stopped_handler(void) {
#ifdef TEST_INCLUDE_BASIC
PropertyAnimation *prop_h;
Layer layer;
GRect from_r;
GRect to_r;
const int duration = 100;
const AnimationHandlers handlers = {
.started = prv_started_handler,
.stopped = prv_stopped_handler_r... | (&layer, 0, sizeof(layer)) | ;
from_r = GRect(0, 0, 100, 200); // x, y, width, height
to_r = GRect(1000, 2000, 100, 200); // x, y, width, height
prop_h = property_animation_create_layer_frame(&layer, &from_r, &to_r);
Animation *h = property_animation_get_animation(prop_h);
void *context = &layer;
animation_set_handlers(h, handlers,... |
st_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_insert_after(&a, &b);
cl_assert(tail == &b);
}
void test_list__insert_before(void) {
ListNode *he... | (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__find_next_and_prev(void) {
IntNode bar[5] = {0};
ListNode* tail = NULL;
for (int i = 0; i < 5; ++i)... |
32_t last_update_utc;
activity_get_metric(ActivityMetricHeartRateFilteredBPM, 1, &last_median);
activity_get_metric(ActivityMetricHeartRateFilteredUpdatedTimeUTC, 1, &last_update_utc);
cl_assert_equal_i(last_median, 0);
cl_assert_equal_i(last_update_utc, 0);
// Simulate some HRM callbacks with no heart rate,... | cl_assert_equal_i(s_last_hr_event.data.heart_rate_update.current_bpm, 0) | ;
cl_assert_equal_i(s_last_hr_event.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... |
= state->samples_per_update - state->num_samples;
ask_for = MAX(ask_for, state->subsample_numerator);
ask_for = ask_for / state->subsample_numerator * state->subsample_numerator;
PBL_ASSERTN(state->num_samples + ask_for <= state->raw_buffer_size);
num_samples = accel_consume_data(state... | DEFINE_SYSCALL(uint32_t, sys_accel_manager_get_buffer_size, AccelSessionRef session,
uint32_t samples_per_update) | {
return samples_per_update + 1;
}
// -------------------------------------------------------------------------------------------
DEFINE_SYSCALL(int, sys_accel_manager_set_sample_buffer, AccelSessionRef session,
AccelRawData *buffer, uint32_t buffer_size, uint32_t samples_per_update) {
int result ... |
104, 64},
{ -736, 32, 176},
// 15 seconds
{ -896, 168, 16},
{ -1112, 560, 176},
{ -1192, -88, -256},
{ -1080, 136, -40},
{ -1528, 192, -168},
{ -1536, 128, -216},
{ -736, 344, -272},
{ -1064, -32, -144},
{ -656, -80, -136},
{ -336, 80, -152},
{ -416, 72, -168},
{ ... | { -408, 744, -608},
{ -824, 392, -168},
{ -880, 288, -312},
{ -1184, 336, -432},
{ -1056, 136, 48},
{ -1712, 288, -392},
{ -1104, 0, 24},
{ -1144, 112, -184},
{ -1032, 264, -136},
{ -736, -8, 40},
{ -560, 216, -72},
{ -544, 192, -80},
{ -832, 240, -216},
{ -960, 1... |
{ -1408, 264, -248},
// 23 seconds
{ -1280, 0, -136},
{ -792, 392, -424},
{ -1056, 192, -280},
{ -736, 64, -160},
{ -320, 64, -144},
{ -448, 136, -336},
{ -696, 136, -312},
{ -888, -128, -64},
{ -1032, 40, -152},
{ -976, 272, -408},
{ -1072, 312, -376},
{ -944, -... |
ch, b->payload_sender_version_patch);
// Ensure they are the same type
cl_assert_equal_i(a->type, b->type);
// MeasurementSet Specific
if (a->type == ProtobufLogType_Measurements) {
cl_assert_equal_i(a->msrmt.time_utc, b->msrmt.time_utc);
cl_assert_equal_i(a->msrmt.utc_to_local, b->msrmt.utc_to_local)... | (s_saved_encoded_msg) | ;
}
return msg;
}
// ---------------------------------------------------------------------------------------------
static ProtobufLogRef *prv_test_encode_measurements(TestPLParsedMsg *input, bool use_data_logging) {
prv_common_payload_initialize(input);
ProtobufLogRef session_ref = prv_log_create_measurement(i... |
/*
* 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... | (pin_config->gpio) | ;
GPIO_Init(pin_config->gpio, &init);
gpio_release(pin_config->gpio);
}
void gpio_output_set(const OutputConfig *pin_config, bool asserted) {
if (!pin_config->active_high) {
asserted = !asserted;
}
gpio_use(pin_config->gpio);
GPIO_WriteBit(pin_config->gpio, pin_config->gpio_pin,
asserte... |
& 0xF0) << 4);
} else if (type == StatusReadType_16bit) {
// The 3 data bytes are SP QR S1 (in hex) with S being the first 4-bits of the address and PQRS
// being the value.
PBL_ASSERTN((response.data[0] & 0xF0) == (address & 0xF0));
PBL_ASSERTN((response.data[2] & 0x0F) == PACKET_FOOTER);
*(uint1... | {
touch_handle_driver_event(TouchDriverEvent_PalmDetect);
} | else if (message.packet_id == PACKET_ID_HELLO) {
// TODO: PBL-29944 handle this gracefully by re-initializing - should "never" happen
PBL_CROAK("Touch controller reset!");
} else {
PBL_LOG(LOG_LEVEL_ERROR, "Got unexpected packet (%"PRIx8")", message.packet_id);
}
}
}
static void prv_exti_c... |
lob.event, type, aux_info);
analytics_logging_log_event(&event_blob);
}
// ------------------------------------------------------------------------------------------
// Log stationary mode events
void analytics_event_stationary_state_change(time_t timestamp, uint8_t state_change) {
AnalyticsEventBlob event_blob = ... | if (conn) {
tmp_conn_interval = conn->conn_params.conn_interval_1_25ms;
} |
}
bt_unlock();
if (is_ppogatt) {
*is_ppogatt = tmp_is_ppogatt;
}
if (conn_interval) {
*conn_interval = tmp_conn_interval;
}
return true;
}
void analytics_event_put_byte_stats(
CommSession *session, bool crc_good, uint8_t type,
uint32_t bytes_transferred, uint32_t elapsed_time_ms,
u... |
option_menu->menu_layer, window);
if (option_menu->choice != OPTION_MENU_CHOICE_NONE) {
menu_layer_set_selected_index(&option_menu->menu_layer, MenuIndex(0, option_menu->choice),
MenuRowAlignCenter, false);
}
layer_add_child(window_get_root_layer(window), menu_layer_get_layer... | window_init(&option_menu->window, WINDOW_NAME("OptionMenu")) | |
/*
* 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... | (s_local_device_name, device_name, sizeof(s_local_device_name)) | |
value_len = strlen(values[0]);
// insert all keys
for (int i = 0; i < ARRAY_LENGTH(keys); ++i) {
blob_db_insert(BlobDBIdTest, (uint8_t *)keys[i], key_len, (uint8_t *)values[i], value_len);
}
cl_assert(blob_db_sync_db(BlobDBIdTest) == S_SUCCESS);
prv_generate_responses_from_phone();
cl_assert_equal_i... | (blob_db_sync_db(id) == S_SUCCESS) | ;
}
void test_blob_db_sync__find_session(void) {
// create a few sync sessions
prv_fill_stop_return_session(BlobDBIdTest);
prv_fill_stop_return_session(BlobDBIdPins);
prv_fill_stop_return_session(BlobDBIdReminders);
// check we can conjure them by id
BlobDBSyncSession *test_session = blob_db_sync_get_sess... |
so
// the active recognizers on non-touched layers in the tree are cancelled
s_active_layer = &layer_b;
e.type = TouchEvent_Touchdown;
recognizer_manager_handle_touch_event(&e, &manager);
prv_compare_recognizers_processed((int[]) {4, 0, 2}, 3, &s_recognizers_handled);
prv_compare_recognizers_processed((int[... | cl_assert_equal_p(manager.triggered, NULL) | ;
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[4]->state, RecognizerState_Possible);
// A touchdown occurs where no layers are touched
s_active_layer = NULL;
e.type = TouchEvent_Touchdow... |
orWhite, NULL, RESOURCE_ID_ACTION_BAR_ICON_CHECK,
prv_alarms_app_opened_click_handler);
expandable_dialog_set_action_bar_background_color(expandable_dialog, ALARMS_APP_HIGHLIGHT_COLOR);
expandable_dialog_set_header(expandable_dialog, header);
#if defined(PBL_ROUND)
expandable_dialog_set_header_font(expanda... | {
prv_handle_init();
app_event_loop();
prv_handle_deinit();
} | |
nable the HR sensor in case we turned it off for a while
static void prv_update_enable_timer_cb(void *context) {
system_task_add_callback(prv_update_hrm_enable_system_cb, NULL);
}
//! The system task needs its own handler for HRM data since we can't queue up generic events.
static void prv_system_task_hrm_handler(vo... | if (state->queue) {
PebbleEvent e = {
.type = PEBBLE_HRM_EVENT,
.hrm = *event,
};
success = xQueueSendToBack(state->queue, &e, 0);
} else {
prv_queue_system_task_event(event);
success = system_task_add_callback(prv_system_task_hrm_handler, NULL);
} |
return success;
}
T_STATIC void prv_charger_event_cb(PebbleEvent *e, void *context) {
const PebbleBatteryStateChangeEvent *evt = &e->battery_state;
mutex_lock_recursive(s_manager_state.lock);
{
s_manager_state.enabled_charging_state = !evt->new_state.is_plugged;
}
mutex_unlock_recursive(s_manager_st... |
esystem by creating a large number
// of small files and only deleting a small number of them
void command_litter_filesystem(void) {
char name[10];
for (int i = 0; i < 100; i++) {
snprintf(name, sizeof(name), "litter%d", i);
int fd = pfs_open(name, OP_FLAG_WRITE, FILE_TYPE_STATIC, 300);
if (i % 5 == 0) ... | bt_driver_stop_unmodulated_tx() | ;
}
void command_btle_test_le_tx_start(
char *tx_channel, char *tx_packet_length, char *packet_payload_type) {
bt_driver_le_transmitter_test(
atoi(tx_channel), atoi(tx_packet_length), atoi(packet_payload_type));
}
void command_btle_test_rx_start(char *rx_channel) {
bt_driver_le_receiver_test(atoi(rx_cha... |
_addr_handle_adverts_stopped(void);
// Accesses to these statics must be protected by prv_lock() calls
static AdvertState s_adv_state = AdvertState_Off;
static AdvertState s_desired_host_adv_state = AdvertState_Off;
static struct {
bool needs_updating;
BLEAdData ad_data;
uint8_t data_buffer[2 * GAP_LE_AD_REPORT... | {
rv = BLE_ERROR_ALREADY_DONE;
goto unlock;
} |
switch (s_adv_state) {
case AdvertState_Pausing:
case AdvertState_Paused:
case AdvertState_Stopping:
// We are transitioning, these are handled by other routines
goto unlock;
default:
break;
}
if (s_desired_host_adv_state == AdvertState_Running) {
//... |
back))consumer->message_handler;
PebbleEvent event = {
.type = PEBBLE_APP_OUTBOX_MSG_EVENT,
.app_outbox_msg = {
.callback = callback,
.data = message,
},
};
sys_send_pebble_event_to_kernel(&event);
}
static uint32_t prv_num_pending_messages(const AppOutboxConsumer *consumer) {
return li... | prv_unlock() | ;
return cancelled;
}
void app_outbox_service_consume_message(AppOutboxMessage *message, AppOutboxStatus status) {
prv_lock();
{
if (app_outbox_service_is_message_cancelled(message)) {
// Don't call the sent_handler
goto finally;
}
AppOutboxConsumer *consumer = prv_find_consumer_with_mess... |
omm_session_event.is_open &&
event->bluetooth.comm_session_event.is_system) {
progress_window_pop(&data->window);
}
}
static void prv_set_progress_failure(AppFetchUIData *data) {
uint32_t icon;
const char *message;
switch (data->result) {
case AppFetchResultNoBluetooth:
icon = TIMELINE_RESO... | {
PBL_LOG(LOG_LEVEL_DEBUG, "App Fetch: Got the start event");
// We have received a new progress event
} | else if (af_event->type == AppFetchEventTypeProgress) {
progress_window_set_progress(&data->window, af_event->progress_percent);
// We have finished the app fetch. Launching
} else if (af_event->type == AppFetchEventTypeFinish) {
progress_window_set_result_success(&data->window);
prv_app_fetch_cleanup... |
/*
* 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_string_for_cmd(clock_cmd) | );
#endif
clock_cmd(rcc_bit, ENABLE);
}
void periph_config_disable(void *periph, uint32_t rcc_bit) {
ClockCmd clock_cmd = prv_get_clock_cmd((uintptr_t)periph);
#if PERIPH_CONFIG_DEBUG
if (prv_string_for_cmd(clock_cmd))
PERIPH_CONFIG_LOG("Disabling clock %s", prv_string_for_cmd(clock_cmd));
#endif
clock_cmd... |
/*
* 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... | line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params) | );
}
void test_line_layout__test_line_add_word_exact_bounds(void) {
// Allocate mutable types
Iterator word_iter = ITERATOR_EMPTY;
WordIterState word_iter_state = WORD_ITER_STATE_EMPTY;
Line line = { 0 };
// Allocate immutable types
bool success = false;
const Utf8Bounds utf8_bounds = utf8_get_bounds(... |
tack);
is_top_discreet = (window && (window == modal_manager_get_top_window()));
} else {
is_top_discreet = (s_last_highest_modal_priority == ModalPriorityDiscreet);
}
return is_top_discreet ? NULL : compositor_modal_transition_to_modal_get(modal_is_destination);
}
static void prv_handle_app_to_modal_tra... | compositor_modal_render_ready() | ;
}
s_last_highest_modal_priority = update.highest_idx;
}
typedef struct IterContext {
Window *current_top_window;
ModalPriority current_idx;
ModalPriority first_visible_idx;
ModalPriority first_transition_idx;
ModalPriority first_focus_idx;
ModalPriority first_opaque_idx;
} IterContext;
typedef bool... |
nds = &utf8_bounds,
.box = (GRect) { GPointZero, (GSize) { 4 * HORIZ_ADVANCE_PX, 90 } }
};
line.max_width_px = text_box_params.box.size.w;
line.height_px = text_box_params.box.size.h;
// Init mutable types
word_iter_init(&word_iter, &word_iter_state, &s_ctx, &text_box_params, utf8_bounds.start);
// Te... | (line.suffix_codepoint == '-') | ;
cl_assert(*line.start == 's');
// le
cl_assert(*word_iter_state.current.start == 'l');
cl_assert(*word_iter_state.current.end == '\0');
cl_assert(word_iter_state.current.width_px == HORIZ_ADVANCE_PX * 2);
line_reset(&line, utf8_bounds.start);
cl_assert(false == line_add_words(&line, &word_iter, NULL))... |
/*
* 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_layer) | ;
}
static void prv_init(void) {
s_window = window_create();
window_set_click_config_provider(s_window, prv_click_config_provider);
window_set_window_handlers(s_window, (WindowHandlers) {
.load = prv_window_load,
.unload = prv_window_unload,
});
const bool animated = true;
window_stack_push(s_windo... |
/*
* 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... | (COUNT_PKEY, num_beers-1) | ;
menu_layer_reload_data(menu_layer);
break;
}
}
}
static void select_long_callback(MenuLayer *menu_layer, MenuIndex *cell_index, AppData *data) {
(void)menu_layer;
(void)data;
switch (cell_index->row) {
case 1: {
int num_beers = persist_read_int(COUNT_PKEY);
persist_write_int(C... |
nst GRect *rect){}
int16_t menu_cell_basic_cell_height(void) {
return 44;
}
// Tests
//////////////////////
static uint16_t s_num_rows;
void test_menu_layer__initialize(void) {
s_num_rows = 10;
}
void test_menu_layer__cleanup(void) {
}
static void prv_draw_row(GContext* ctx,
const La... | (10, 10, height, 180) | );
menu_layer_set_callbacks(&l, NULL, &(MenuLayerCallbacks){
.draw_row = prv_draw_row,
.get_num_rows = prv_get_num_rows,
.get_cell_height = prv_get_row_height_depending_on_selection_state,
});
cl_assert_equal_i(0, menu_layer_get_selected_index(&l).row);
cl_assert_equal_i(0, l.selection.y);
c... |
6),
ROCKY_ARG(u32),
ROCKY_ARG(u64),
ROCKY_ARG(s8),
ROCKY_ARG(s16),
ROCKY_ARG(s32),
ROCKY_ARG(s64),
ROCKY_ARG(d),
);
ASSERT_JS_ERROR(error_value, c->expected_error_msg);
if (!c->expected_error_msg) {
cl_assert_equal_i(u8, (uint8_t)c->u8);
cl... | jerry_create_number(1.234e+60) | ,
.expected_output = "1.234e+60",
},
{
.input = jerry_create_string((const jerry_char_t *)""),
.expected_output = "",
},
{
.input = jerry_create_string((const jerry_char_t *)"js"),
.expected_output = "js",
},
{
.input = jerry_create_null(),
.expected_out... |
// Unaligned start, even length - Need to pad both ends
// Unaligned start, odd length - Pad the start
// Aligned start, odd length - Pad the end
if (start_addr & 0x1 || bytes_in_page & 0x1) {
++num_shorts;
}
const FlashAddress sector_addr =
flash_impl_get_sector_base_address(start_addr);
flash_im... | prv_allow_write_if_sector_is_not_protected(true, sector_addr) | ;
flash_impl_release();
return FAILED(result) ? result : (int)bytes_in_page;
}
status_t flash_impl_get_write_status(void) {
flash_impl_use();
const uint8_t status = prv_read_status_register(0);
flash_impl_release();
if ((status & S29VSStatusBit_DeviceReady) == 0) return E_BUSY;
if ((status & S29VSStatus... |
nclude "kernel/pbl_malloc.h"
#include "resource/resource_ids.auto.h"
#include "services/common/clock.h"
#include "services/common/i18n/i18n.h"
#include "services/normal/activity/activity_private.h"
#include "services/normal/activity/health_util.h"
#include "services/normal/activity/hr_util.h"
#include "services/normal/... | ("AVG PACE (/MI)") | ,
i18n_noop("AVG PACE (/KM)"));
#endif
case WorkoutMetricType_Pace:
#if PBL_RECT
/// Pace Label
return i18n_noop("PACE");
#else
/// Pace Label with units
return active_window->workout_controller->get_distance_string(i18n_noo... |
int,
.teardown = prv_teardown_handler
},
.accessors = {
.setter = { .int16 = (const Int16Setter) prv_gpoint_setter, },
.getter = { .int16 = (const Int16Getter) prv_gpoint_getter },
},
};
// Implementation
cl_assert(animation_get_implementation(h) == &implementation.base);
animatio... | (&s_stopped_handler_calls, a) | |
, 368, -816},
{ 360, 400, -808},
{ 368, 408, -816},
{ 368, 368, -816},
{ 360, 392, -824},
{ 360, 384, -816},
{ 344, 376, -800},
{ 360, 456, -800},
// 184 seconds
{ 360, 392, -808},
{ 360, 360, -816},
{ 368, 424, -808},
{ 368, 400, -808},
{ 360, 360, -808},
{ 368, ... | { 384, 416, -784},
{ 408, 392, -776},
{ 392, 400, -784},
{ 384, 424, -792},
{ 376, 416, -800},
{ 384, 408, -792},
{ 384, 408, -792},
{ 376, 400, -800},
{ 384, 416, -792},
{ 384, 392, -800},
{ 376, 408, -800},
{ 376, 408, -800},
{ 376, 384, -808},
{ 376, 400, -800}... |
{ 520, 416, -744},
// 192 seconds
{ 536, 416, -696},
{ 520, 392, -688},
{ 528, 424, -696},
{ 536, 416, -704},
{ 528, 440, -704},
{ 528, 408, -728},
{ 536, 416, -720},
{ 544, 392, -720},
{ 536, 384, -680},
{ 544, 384, -640},
{ 544, 376, -656},
{ 472, 488, -840},
... |
/*
* 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 ((cursor >= end) || (word->length == 0) || (word->data + word->length > end) ||
!prv_validate_word(word->data, word->length)) {
return false;
} |
cursor += word->length;
}
sentence = (TranscriptionSentence *)cursor;
}
return (cursor == end);
}
void *transcription_iterate_sentences(const TranscriptionSentence *sentence, size_t count,
TranscriptionSentenceIterateCb handle_sentence, void *data) {
for (size_t i = 0; i < count; i++) {
... |
otal_size * 1000) / elapsed_time_ms);
PBL_LOG(LOG_LEVEL_DEBUG, "PutBytes pushed %d bytes/sec", bytes_per_sec);
}
bluetooth_analytics_handle_put_bytes_stats(
commit_succeeded, s_pb_state.type,
s_pb_state.total_size, elapsed_time_ms, &s_pb_state.conn_event_stats);
if (commit_succeeded) {
s_pb_... | (s_pb_semaphore, portMAX_DELAY) | |
ress or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "rocky_api_graphics_color.h"
#include "rocky_api_util.h"
#include "string.h"
#include "util/size.h"
#define GColorARGB8FromRGBA(red, green, blue, alpha) \
(uint8_t)( \
((((alp... | (0x808080) | },
{"honeydew", GColorARGB8FromHEX(0xf0fff0)},
{"hotpink", GColorARGB8FromHEX(0xff69b4)},
{"indianred", GColorARGB8FromHEX(0xcd5c5c)},
// {"indigo", GColorARGBFromHEX(0x4b0082)}, inconsistent with Pebble color
{"ivory", GColorARGB8FromHEX(0xfffff0)},
{"khaki", GColorARGB8FromHEX(0xf0e68c)},
{"lavender", GC... |
loc.h"
#include "process_state/app_state/app_state.h"
#include "services/normal/activity/activity_algorithm.h"
#include "services/normal/activity/activity_insights.h"
#include "services/normal/data_logging/data_logging_service.h"
#include "shell/prefs.h"
#include "system/logging.h"
#include "util/size.h"
#include "util... | (temp, sizeof(temp), "\n%d: %s", i, elapsed) | ;
strcat(data->debug_card.dialog_text, temp);
}
prv_display_alert(data->debug_card.dialog_text);
}
// -----------------------------------------------------------------------------------------
static void prv_set_steps(int32_t steps, ActivityDemoAppData *data) {
activity_test_set_steps_and_avg(steps, CURRENT... |
cess_manager_compiled_with_legacy2_sdk();
const GRect frame = window_calc_frame(fullscreen);
layer_init(&window->layer, &frame);
window->is_fullscreen = fullscreen;
window->layer.window = window;
window->layer.update_proc = window_do_layer_update_proc;
window->background_color = GColorWhite;
window->in_cl... | prv_get_current_click_manager() | ;
ClickConfig *cfg = &mgr->recognizers[button_id].config;
cfg->multi_click.min = (min_clicks == 0) ? 2 : min_clicks;
cfg->multi_click.max = (max_clicks == 0) ? min_clicks : max_clicks;
cfg->multi_click.timeout = (timeout == 0) ? 300 : timeout;
cfg->multi_click.last_click_only = last_click_only;
cfg->multi_... |
---------------------------------------
// Test derived metrics based on sleep data
void test_activity__sleep_derived_metrics(void) {
int32_t value;
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke system callbacks to handle its KernelBG callback.
activity_st... | {
// Start activity tracking. This method assumes it can be called from any task, so we must
// invoke system callbacks to handle its KernelBG callback.
activity_start_tracking(false /*test_mode*/);
fake_system_task_callbacks_invoke_pending();
// All of our tests start at 5pm. Let's enter a sleep cycle where... |
150 * SECONDS_PER_MINUTE}));
// Another 2 hour sleep session starting at 1am. This will leave us at 3am.
prv_feed_cannned_accel_data(120 * SECONDS_PER_MINUTE, 0, ActivitySleepStateLightSleep);
// Awake for 1 hour which puts us at 4am
prv_feed_cannned_accel_data... |
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->fastcharge_enabled) ... | (details,
&GRect(0, 65, window->layer.bounds.size.w, window->layer.bounds.size.h - 65)) | ;
text_layer_set_font(details, fonts_get_system_font(FONT_KEY_GOTHIC_24));
text_layer_set_text_alignment(details, GTextAlignmentCenter);
layer_add_child(&window->layer, &details->layer);
window_set_click_config_provider(window, prv_config_provider);
window_set_fullscreen(window, true);
tick_timer_service_... |
ribed with no end in sight
workout_service_frontend_opened();
cl_assert_equal_b(s_hrm_subscribed, true);
cl_assert_equal_i(s_hrm_expiration, 0);
prv_inc_time(1 * SECONDS_PER_MINUTE);
cl_assert(workout_service_start_workout(ActivitySessionType_Run));
// Workout of 120 seconds duration. Should be valid
prv... | (hr_zone_time_s[HRZone_Zone1], 20) | ;
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone2], 10);
cl_assert_equal_i(hr_zone_time_s[HRZone_Zone3], 10);
// Pause the workout. Don't accumulate time in zones
cl_assert(workout_service_pause_workout(true));
prv_inc_time(10);
prv_put_bpm_event(ZONE_3_HR, HRMQuality_Good);
cl_assert(workout_service_get_... |
/*
* 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... | (BITS_BETWEEN(1, 10), erased_sector) | ;
cl_assert(flash_locked);
}
void callback_is_called_cb(uint32_t num, uint32_t den, void *context) {
callback_called = true;
cl_assert_equal_i(8675309, (uintptr_t)context);
}
void test_system_flash__callback_is_called(void) {
cl_assert(system_flash_erase(FLASH_BASE, 16 KiB, callback_is_called_cb,
... |
tack(ModalPriorityNotification));
}
static void prv_push_smart_dnd_first_use_dialog(void) {
const char *msg = i18n_get("Calendar Aware enables Quiet Time automatically during " \
"calendar events.", &s_data);
prv_push_first_use_dialog(msg, prv_toggle_smart_dnd);
}
static void prv_push_manual_dnd_first_use_d... | PBL_LOG(LOG_LEVEL_INFO, "%s scheduled period. %u seconds until update",
s_data.is_in_schedule_period ? "In" : "Out of", (unsigned int) seconds_until_update) | ;
bool success = new_timer_start(s_data.update_timer_id, seconds_until_update * 1000,
prv_update_schedule_mode_timer_callback, NULL, 0 /*flags*/);
PBL_ASSERTN(success);
}
static bool prv_is_current_schedule_enabled() {
return (do_not_disturb_is_schedule_enabled(prv_current_sched... |
// correctly. That is, we add the window to the window stack, its load handler is
// called, it calls to set the click config, and the click config is set properly.
void test_window_stack__window_flow(void) {
Window *window = window_create();
window_set_window_handlers(window, &(WindowHandlers){
.load = prv_w... | (PebbleTask_App) | ;
cl_check(stack);
cl_assert_equal_i(window_stack_count(stack), 0);
window_stack_push(stack, window, true);
cl_assert_equal_i(window_stack_count(stack), 0);
// We popped the window off the screen, but the unload handler
// should not have been called for it, as it hasn't finished
// unloading.
cl_as... |
/*
* 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... | (dstbuf, "There are 4 lights, -4") | ;
// Left-align, Space padded minimum character output
snprintf(dstbuf, 256, "There are %-2d lights, %-2d", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, -4");
// Space for positive signed
snprintf(dstbuf, 256, "There are % d lights, the absolute value of % d", 4, -4);
cl_assert_equal_s(dstbuf, ... |
/*
* 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_NAME("Health") | );
Layer *window_layer = window_get_root_layer(&window);
Layer *card_layer = health_hr_summary_card_create(health_data);
layer_set_frame(card_layer, &window_layer->bounds);
layer_add_child(window_layer, card_layer);
window_set_background_color(&window, health_hr_summary_card_get_bg_color(card_layer));
windo... |
{ 48, 16, -1008},
{ 48, 24, -1000},
{ 40, 24, -1000},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 24, -1008},
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 16... |
{ 48, 16, -1000},
{ 48, 16, -1008},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 24, -1000},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 24, -1000},
{ 40, 24, -992},
{ 48, 16, -1000},
{ 48, 24, -1000},
{ 48, 16, -1000},
{ 48, 16, -992},
{ 48, 16, -1000},
{ 56, 24,... | |
nit_with_resource(&s_app_icon_bitmap, node->icon_resource_id);
return &s_app_icon_bitmap;
}
//! We use this function in the app glance service to create a key (the install ID) for an app
//! glance cache entry; just fake it by constructing a 32-bit number from the first 4 bytes of the
//! app's UUID
AppInstallId app... | (&s_app_icon_bitmap) | ;
gbitmap_deinit(&s_default_app_icon_bitmap);
free(fb);
}
// Helpers
//////////////////////
//! Declared T_STATIC in launcher_menu_layer.c so we can easily change the launcher's selected index
//! from unit tests without also specifying the y offset for the scroll layer that is required by
//! `launcher_menu_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... | if (is_increased) {
if (nf->callbacks.incremented != NULL) {
nf->callbacks.incremented(nf, nf->callback_context);
}
update_output_value(nf);
} |
}
static void down_click_handler(ClickRecognizerRef recognizer, NumberWindow *nf) {
bool is_decreased = false;
int32_t new_val = nf->value - nf->step_size;
if (new_val >= nf->min_val && new_val < nf->value) {
nf->value = new_val;
is_decreased = true;
}
if (is_decreased) {
if (nf->callbacks.decre... |
cl_assert_equal_point(GPoint(6, 7), lc->path.points[3]) | ;
}
void test_rocky_api_graphics_path2d__fill(void) {
rocky_global_init(s_graphics_api);
prv_create_global_ctx();
EXECUTE_SCRIPT(
"ctx.moveTo(1, 2);\n"
"ctx.lineTo(3, 4);\n"
"ctx.fill();\n"
);
// only 2 points
cl_assert_equal_i(0, s_gpath_draw_filled.call_count);
EXECUTE_SCRIPT(
"ctx.l... | |
/*
* 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_main() | ;
emx_app_deinit();
return 0;
}
|
nk_key_out, sizeof(link_key_out));
cl_assert_equal_s(name_in, name_out);
cl_assert_equal_i(platform_bits_in, platform_bits_out);
}
void test_bluetooth_persistent_storage_prf__delete_bt_classic_pairing_by_id(void) {
bool ret;
// Output variables
BTDeviceAddress addr_out;
SM128BitKey link_key_out;
char na... | cl_assert(!ret) | ;
ret = bt_persistent_storage_has_active_ble_gateway_bonding();
cl_assert(!ret);
// Store a new BT Classic pairing
BTDeviceAddress addr_1 = {.octets = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16}};
SM128BitKey link_key_1 = {
.data = {
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, ... |
e_clients(intent, HciStatusCode_Success,
GAPLEConnectionEventConnectedAndEncrypted);
}
//! bt_lock is assumed to be taken before calling this function.
void bt_driver_handle_le_encryption_change_event(const BleEncryptionChange *event) {
bt_lock();
const bool is_encrypted = (event->encryption_e... | BLE_GAP_LOG_DEBUG("Mutating white-list (adding=%u): " BD_ADDR_FMT,
is_adding, BT_DEVICE_ADDRESS_XPLODE(device->address)) | ;
// See Bluetooth Spec 4.0, Volume 2, Part E, Chapter 7.8.15:
uint8_t status = 0;
const uint8_t addr_type = device->is_random_address ? 0x01 : 0x00;
__typeof__(&HCI_LE_Add_Device_To_White_List) mutator =
(is_adding ? HCI_LE_Add_Device_To_White_List : HCI_LE_Remove_Device_From_White_List);
const int r... |
// the peek animation
notifications_presented_list_set_current(id);
prv_show_peek_for_notification(data, id, false /* is_first_notification */);
return;
#endif
}
// Animated was set to false or there was no notification after the focusing one.
// Just set the current notification and reload data.
n... | alerts_should_enable_backlight_for_type(prv_alert_type_for_notification_type(type)) | ) {
light_enable_interaction();
}
prv_refresh_pop_timer(data);
}
static bool prv_is_item_loaded(Uuid *id) {
return (uuid_equal(id, notifications_presented_list_current()) ||
uuid_equal(id, notifications_presented_list_next()));
}
static void prv_handle_reminder_updated(Uuid *id) {
NotificationW... |
ributeIdSubtitle);
cl_assert_equal_s(item->attr_list.attributes[1].cstring, "Subtitle");
cl_assert_equal_i(item->attr_list.attributes[2].id, AttributeIdBody);
cl_assert_equal_s(item->attr_list.attributes[2].cstring, "This is a test notification. "
"L... | cl_assert_equal_i(2, string_list_count(list)) | ;
cl_assert_equal_s("ab", string_list_get_at(list, 0));
cl_assert_equal_s("", string_list_get_at(list, 1));
// 2 strings (non-null terminated) - this is the standard case
list->serialized_byte_length = 4;
list->data[0] = 'a';
list->data[1] = 'b';
list->data[2] = '\0';
list->data[3] = 'c'; // end of dat... |
_BYTES(endpoint_id, length, ...) \
{ \
length & 0xff, length >> 8, \
endpoint_id && 0xff, endpoint_id >> 8, \
__VA_ARGS__ \
}
#define RECEIVE(...) \
{ \
const uint8_t partial_data[] = { __VA_ARGS__ }; \
comm_session_receive_router_write(s_session, partial_data, sizeof(partial_data)); \
}
s... | (s_protocol_callback_counts, 0, sizeof(s_protocol_callback_counts)) | ;
s_prepare_count = 0;
s_finish_count = 0;
s_cleanup_count = 0;
s_write_length = 0;
s_last_meta_response_info = (const MetaResponseInfo) {};
s_prepare_return_null = false;
}
void test_session_receive_router__cleanup(void) {
if (s_session) {
comm_session_close(s_session, CommSessionCloseReason_Underly... |
/*
* 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_remove(b, 0, 0) | );
cl_assert_passert(buffer_remove(b, 0, 1));
uint8_t b1 = 1;
buffer_add(b, &b1, sizeof(uint8_t));
cl_assert_passert(buffer_remove(b, 0, 2));
cl_assert_equal_i(1, b->bytes_written);
cl_assert_equal_i(1, buffer_remove(b, 0, 1));
cl_assert_equal_i(0, b->bytes_written);
free(b);
}
void test_buffer__can... |
6 == -16);
int16_found = true;
break;
case SOME_INT32_KEY:
cl_assert(tuple->length == sizeof(int32_t));
cl_assert(tuple->value->int32 == -32);
int32_found = true;
break;
case SOME_NULL_KEY:
cl_assert(tuple->length == 0);
null_cstring_found = tr... | dict_calc_buffer_size_from_tuplets(source_tuplets, ARRAY_LENGTH(source_tuplets)) | ;
const uint32_t min_dest_size = dict_calc_buffer_size_from_tuplets(dest_tuplets, ARRAY_LENGTH(dest_tuplets));
const uint32_t dest_size = test_not_enough_storage ? min_dest_size : min_dest_size + source_size;
uint8_t source_buffer[source_size];
tmp_size = source_size; // dict_serialize_tuplets_to_buff... |
i = 0; i < s_num_dls_activity_records; i++) {
if (!memcmp(record, &s_dls_activity_records[i], sizeof(*record))) {
return;
}
}
printf("\nFound records:");
for (int i = 0; i < s_num_dls_activity_records; i++) {
printf("\ntype: %d, start_utc: %"PRIu32", elapsed: %"PRIu32", utc_to_local: %"PRIu32" "... | {
ActivitySession sessions[ACTIVITY_MAX_ACTIVITY_SESSIONS_COUNT];
uint32_t num_sessions = ACTIVITY_MAX_ACTIVITY_SESSIONS_COUNT;
activity_get_sessions(&num_sessions, sessions);
for (int i = 0; i < num_sessions; i++) {
if (sessions[i].type == exp_session->type
&& sessions[i].start_utc == exp_session->... |
#define ASSERT_STEP_ACTIVITY_SESSION_PRESENT(session) \
prv_assert_step_activity_present((session), __FILE__, __LINE__)
#define ASSERT_SLEEP_ACTIVITY_SESSION_PRESENT(session) \
prv_assert_sleep_activity_present((session), __FILE__, __LINE__)
#define ASSERT_NUM_ACTIVITY_SESSIONS(num_sessions) \
... |
/*
* 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... | PBL_LOG(LOG_LEVEL_DEBUG, ">> Addr 0x%x is 0x%"PRIx16, BASE_ADDRESS, buffer) | ;
buffer = 0x0505;
flash_write_bytes((uint8_t*) &buffer, BASE_ADDRESS, sizeof(buffer));
PBL_LOG(LOG_LEVEL_DEBUG, ">> Addr 0x%x Written to 0x%x", BASE_ADDRESS, buffer);
uint8_t read_buffer = 0x0;
flash_read_bytes((uint8_t*) &read_buffer, BASE_ADDRESS, sizeof(read_buffer));
PBL_LOG(LOG_LEVEL_DEBUG, ">> Addr... |
ess_all_recognizers(&manager, prv_handle_dummy_touch_event, NULL);
// One recognizer attached to the active layer
recognizer_add_to_list(recognizers[0], &layer_c.recognizer_list);
cl_assert(prv_process_all_recognizers(&manager, prv_handle_dummy_touch_event, NULL));
prv_compare_recognizers_processed((int[]) {0}... | cl_assert(prv_dispatch_touch_event(r, &ctx)) | ;
cl_assert(!handled);
recognizer_set_simultaneous_with(r, prv_simultaneous_with_cb);
cl_assert(prv_dispatch_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... |
/*
* 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... | w = bounds->size.w - left_margin_px - right_margin_px;
GTextAttributes *text_attributes = NULL;
#if PBL_ROUND
// Create a GTextAttributes for the TextLayer. Note that the matching
// graphics_text_attributes_destroy() will not need to be called here, as the ownership
// of text_attributes will be transferred... |
text_alignment,
text_attributes).h;
if (text_height <= single_line_text_height_px) {
text_top_margin_px += text_single_line_text_offset_px;
icon_top_margin_px ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.