prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
{
prv_lock();
prv_invalidate_current_page();
prv_unlock();
} |
//!
//! Custom Local Device Name APIs
//!
bool shared_prf_storage_get_local_device_name(char *local_device_name_out, size_t max_size) {
bool rv;
prv_lock();
{
SprfLocalName data;
rv = SPRF_FETCH_FIELD(data, local_name);
if (!rv) {
goto unlock;
}
if (local_device_name_out) {
str... | |
},
{ -328, 528, 448},
{ -448, 664, 512},
{ -424, 840, 560},
{ -376, 792, 408},
{ -288, 816, 376},
{ -328, 952, 400},
{ -288, 792, 200},
{ -336, 808, 112},
{ -432, 848, 40},
{ -472, 680, 64},
{ -560, 872, 48},
{ -552, 864, -8},
{ -440, 792, 0},
{ -520, 1008, -8},
... | { -112, 920, -224},
{ -120, 928, -200},
{ -104, 944, -216},
{ -104, 928, -168},
{ -112, 872, -168},
{ -96, 880, -224},
{ -136, 944, -216},
{ -152, 1168, -280},
{ -200, 1088, -328},
{ -320, 984, -248},
// 58 seconds
{ -416, 1096, -216},
{ -424, 496, -280},
{ -160, ... |
{ -384, 752, -424},
{ -400, 760, -448},
{ -384, 848, -424},
{ -344, 600, -416},
{ -384, 840, -408},
{ -392, 792, -424},
{ -392, 824, -440},
{ -408, 808, -392},
{ -408, 776, -336},
{ -416, 792, -440},
{ -392, 816, -280},
{ -416, 808, -368},
{ -400, 856, -408},
{ -... |
/*
* 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... | {
memset(s, c, n);
} |
void __aeabi_memclr(void *addr, size_t n) {
memset(addr, 0, n);
}
ALIAS("__aeabi_memclr") void __aeabi_memclr4(void *s, size_t n);
ALIAS("__aeabi_memclr") void __aeabi_memclr8(void *s, size_t n);
#endif
|
window) {
ActionableDialog *actionable_dialog = window_get_user_data(window);
Dialog *dialog = &actionable_dialog->dialog;
Layer *window_root_layer = window_get_root_layer(window);
// Ownership of icon is taken over by KinoLayer in dialog_init_icon_layer() call below
KinoReel *icon = dialog_create_icon(dialo... | if (text_attributes) {
text_layer->should_cache_layout = true;
text_layer->layout_cache = text_attributes;
} |
layer_add_child(&window->layer, &text_layer->layer);
// Action bar. If the user hasn't given a custom action bar, we'll create one of the preset
// types.
if (actionable_dialog->action_bar_type != DialogActionBarCustom) {
actionable_dialog->action_bar = action_bar_layer_create();
action_bar_layer_set... |
GRect screen_frame) {
return NULL;
}
void kino_reel_scale_segmented_set_deflate_effect(KinoReel *reel, int16_t expand) {}
bool kino_reel_scale_segmented_set_delay_by_distance(KinoReel *reel, GPoint target) {
return false;
}
// Helper Functions
/////////////////////
#include "../graphics/test_graphics.h... | ("Battery Status") | ;
Dialog *dialog = simple_dialog_get_dialog(simple_dialog);
uint32_t percent = 20;
dialog_set_background_color(dialog, GColorRed);
char buffer[25];
snprintf(buffer, sizeof(buffer), "%d%% Battery", percent);
dialog_set_text(dialog, buffer);
dialog_set_icon(dialog, RESOURCE_ID_BATTERY_ICON_LOW_LARGE);
pr... |
/*
* 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(data->new_state && (*data->new_state != RecognizerState_Possible)) {
cl_assert(data->updated);
cl_assert_equal_p(*data->updated, false);
*data->updated = true;
recognizer_transition_state(recognizer, *data->new_state);
} |
}
static bool prv_cancel(Recognizer *recognizer) {
TestImplData *data = recognizer_get_impl_data(recognizer, &s_test_impl);
cl_assert_equal_i(data->test, TEST_PATTERN);
if (data->cancelled) {
cl_assert_equal_b(*data->cancelled, false);
*data->cancelled = true;
}
return true;
}
static void prv_reset... |
igin.x, layer.frame.origin.y,
layer.frame.size.w, layer.frame.size.h);
if (layer.frame.origin.x == to_r.origin.x && layer.frame.origin.y == to_r.origin.y) {
reached_end_elapsed = true;
}
if (reached_end_elapsed && s_stopped_handler_calls.num_calls == 1
&& layer.frame.origin.x < to... | {
detected_reset_of_elapsed = true;
} |
cl_assert(max_loops > 0);
max_loops--;
}
// Make sure we detected a reset of the elapsed after rescheduling
cl_assert(s_stopped_handler_calls.num_calls == 2);
cl_assert(detected_reset_of_elapsed);
// Make sure the frame reached the "to" state
cl_assert_equal_point(layer.frame.origin, to_r.origin... |
name);
pfs_remove(iter->name);
iter = (PFSFileListEntry *)iter->list_node.next;
}
}
// The bug addressed in PBL-34010 caused resource files to remain in the filesystem even
// after the associated application had been deleted. This function attempts to find such
// orphaned files and remove them. Note: fur... | (s_app_cache_mutex) | ;
}
////////////////////////////////
// Testing only
////////////////////////////////
static bool prv_each_get_size(SettingsFile *file, SettingsRecordInfo *info, void *context) {
if ((info->key_len != sizeof(AppInstallId)) || (info->val_len != sizeof(AppCacheEntry))) {
return true; // continue iterating
}
... |
LL_HEIGHT);
box.origin = GPoint(0, 4);
graphics_draw_text(ctx, i18n_get("Check something first.",
&data->custom_day_picker_window),
fonts_get_system_font(FONT_KEY_GOTHIC_18), box, GTextOverflowModeFill,
... | ("Alarm Custom Day Picker") | );
window_set_user_data(&data->custom_day_picker_window, data);
data->custom_day_picker_window.window_handlers.unload = prv_custom_day_picker_window_unload;
GRect bounds = data->custom_day_picker_window.layer.bounds;
#if PBL_ROUND
bounds = grect_inset_internal(bounds, 0, STATUS_BAR_LAYER_HEIGHT);
#endif
menu... |
// Keep a write offset, this won't work when we try to roll over to the other 25% of the sectors
if (s_valid_page_idx == SPRF_PAGE_IDX_INVALID) {
prv_erase_region_and_save(NULL);
} else if (s_valid_page_idx > (SPRF_MAX_NUM_PAGES_MULT(SPRF_NUM_PAGES))) {
prv_erase_region_and_save(&data);
}
}... | // Should we return a failure on a failed name get?
if (name_rv) {
strncpy(name_out, name_data.name, BT_DEVICE_NAME_BUFFER_SIZE);
} else {
name_out[0] = '\0';
}
}
rv = true;
} |
unlock:
prv_unlock();
return rv;
}
void shared_prf_storage_store_ble_pairing_data(
const SMPairingInfo *pairing_info, const char *name, bool requires_address_pinning,
uint8_t flags) {
if (!pairing_info || sm_is_pairing_info_empty(pairing_info)) {
PBL_LOG(LOG_LEVEL_WARNING, "PRF Storage: Attempting ... |
trap_link_control.h"
#include "services/normal/accessory/smartstrap_state.h"
#include "syscall/syscall.h"
#include "syscall/syscall_internal.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/attributes.h"
#include "util/mbuf.h"
#define MAX_SERVICES 10
#define MIN_SERVICE_ID ... | (LOG_LEVEL_DEBUG, "Sent service discovery message (result=%d)", result) | ;
}
static void prv_set_connected(bool connected) {
s_has_done_service_discovery = false;
}
static bool prv_handle_management_attribute_read(bool success, ManagementServiceAttribute attr,
void *data, uint32_t length) {
if (!success) {
PBL_LOG(LOG_LEVEL_DEBUG, "... |
040, 376, 224},
{ 1448, 320, 216},
{ 1696, 104, 456},
{ 1720, -136, 480},
{ 1432, -176, 384},
{ 1304, -136, 288},
{ 1240, -136, 272},
{ 1192, -168, 264},
{ 1152, -240, 192},
{ 1048, -248, 112},
// 27 seconds
{ 1000, -328, 56},
{ 936, -392, 48},
{ 1000, -344, -48},
... | { 1296, -160, 128},
{ 1536, -104, 80},
{ 1472, -144, 152},
{ 1184, 24, 208},
{ 976, 160, 184},
{ 912, 192, 184},
{ 1056, 136, 176},
{ 1056, 248, 120},
{ 1216, 456, 96},
{ 1392, 480, 232},
{ 1568, 400, 408},
{ 1152, 416, 240},
{ 1152, 208, 168},
{ 1688, -16, 440},
... |
{ 1200, -104, 232},
{ 1200, -208, 256},
{ 1128, -288, 144},
{ 1016, -424, 56},
// 35 seconds
{ 984, -440, 8},
{ 1112, -552, 48},
{ 928, -384, -24},
{ 1056, -288, 72},
{ 1304, -176, 96},
{ 1656, -160, 232},
{ 1560, -24, 136},
{ 1128, -8, 288},
{ 944, 96, 176},
... |
-4);
cl_assert_equal_s(dstbuf, "There are 4 lights, 4294967292");
// Alternate form
snprintf(dstbuf, 256, "There are %#u lights, %#u", 4, -4);
cl_assert_equal_s(dstbuf, "There are 4 lights, 4294967292");
// Zero padded minimum character output
snprintf(dstbuf, 256, "There are %02u lights, %02u", 4, -4);
... | (dstbuf, 256, "%.0ozero%.0o", 0, 1) | ;
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (unspecified digits, acts as zero)
snprintf(dstbuf, 256, "%.ozero%.o", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (negative digits, acts as zero)
snprintf(dstbuf, 256, "%.-3ozero%.-3o", 0, 1);
cl_assert_equal_s(dstbu... |
/*
* 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... | (&gatt_event) | |
nt delay = atoi(delay_arg);
if (count <= 0 || count > 0xFFFF || delay <= 0 || delay > 0xFFFF) {
prompt_send_response("Nope.");
return;
}
struct WasteTimerData data = { count, delay };
uintptr_t data_pack;
memcpy(&data_pack, &data, sizeof data_pack);
if (s_abusive_timer == TIMER_INVALID_ID) {
... | atoi(start_handle) | |
place dot in middle of layer
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_circle(ctx, grect_center_point(&layer->bounds), data->mic_window.mic_dot_radius);
}
static void prv_set_dot_width(void *subject, int16_t radius) {
VoiceUiData *data = subject;
data->mic_window.mic_dot_radius = radius;... | (&data->mic_window.icon_layer) | ;
GRect from = kino_reel_transform_get_from_frame(reel);
GRect to = kino_reel_transform_get_to_frame(reel);
kino_reel_scale_segmented_set_from_stroke_width(reel, FIXED_S16_3_ONE, GStrokeWidthOpMultiply);
kino_reel_scale_segmented_set_to_stroke_width(reel, FIXED_S16_3_ONE, GStrokeWidthOpMultiply);
if (is_reve... |
/*
* 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... | (prop_animation, &window_to_end) | |
is_active();
cl_assert(active == true);
do_not_disturb_set_manually_enabled(false);
active = do_not_disturb_is_active();
cl_assert(active == false);
}
void test_do_not_disturb__is_active(void) {
// Time 00:00, Manual and Scheduled DND both OFF
bool active;
// !Manual && !Scheduled && !Smart
cl_assert... | do_not_disturb_set_manually_enabled(true) | ; // both ON
cl_assert(do_not_disturb_is_manually_enabled() == true);
cl_assert(do_not_disturb_is_schedule_enabled(WeekdaySchedule) == true);
active = do_not_disturb_is_active();
cl_assert(active == true); // Both OFF
do_not_disturb_set_manually_enabled(false); // turned Manual OFF, scheduled should be overr... |
/*
* 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_is_transparent(bg_color)) {
GDrawState prev_state = graphics_context_get_drawing_state(ctx);
graphics_context_set_fill_color(ctx, bg_color);
graphics_fill_rect(ctx, &layer->bounds);
graphics_context_set_drawing_state(ctx, prev_state);
} | |
e *cur_node, void *data) {
BlobDBDirtyItem *dirty_item = (BlobDBDirtyItem *)cur_node;
char *key = data;
return (memcmp(dirty_item->key, key, dirty_item->key_len) == 0);
}
void test_blob_db_sync__dirty_list(void) {
uint8_t ids[NumBlobDBs];
uint8_t num_ids;
blob_db_get_dirty_dbs(ids, &num_ids);
cl_assert_e... | (s_num_writebacks, 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... | if ((byte & 0x80) == 0) {
// the count is 1 byte (1-127)
ctx->zeros_remaining = byte - 1;
} else {
ctx->zeros_remaining = (((byte & 0x7f) << 8) | *(ctx->sle_buffer++)) + 0x80 - 1;
} | |
/*
* 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 (boot_version_read() == s_bootloader_timestamp) {
return;
} |
RTC_WriteBackupRegister(BOOTLOADER_VERSION_REGISTER, s_bootloader_timestamp);
}
uint32_t boot_version_read(void) {
return RTC_ReadBackupRegister(BOOTLOADER_VERSION_REGISTER);
}
|
20, 608, 48},
{ 312, 816, 56},
{ 264, 912, 64},
{ 288, 944, -88},
{ 320, 848, 72},
{ 280, 976, -88},
{ 272, 944, 16},
{ 320, 1104, 312},
{ 8, 1704, 504},
{ 144, 1512, 376},
{ 256, 1168, 328},
{ 104, 960, 352},
{ 104, 768, 224},
{ 152, 544, 184},
{ 200, 608, 216},
... | { -112, 1440, 336},
{ -88, 1288, 16},
{ 96, 1064, 48},
// 33 seconds
{ 160, 800, 8},
{ 240, 752, 32},
{ 256, 560, 72},
{ 272, 632, 40},
{ 232, 808, 96},
{ 224, 1000, -64},
{ 304, 1192, 216},
{ 304, 1192, 144},
{ 304, 1008, 136},
{ 288, 1320, 352},
{ -64, 1272,... |
{ 264, 104, -576},
{ 288, 200, -656},
{ 304, 120, -664},
{ 456, 88, -816},
{ 208, 152, -1000},
{ 136, -160, -720},
{ 120, 512, -544},
{ 40, 984, 200},
{ -80, 2104, -504},
// 36 seconds
{ 8, 1040, 336},
{ 216, 1024, 128},
{ 216, 784, 168},
{ 264, 696, 288},
{ ... |
is 54MHz, so we want the smallest prescaler
spi_cfg.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
spi_cfg.SPI_FirstBit = SPI_FirstBit_MSB;
spi_cfg.SPI_CRCPolynomial = 7;
SPI_Init(FLASH_CONFIG.spi, &spi_cfg);
SPI_Cmd(FLASH_CONFIG.spi, ENABLE);
gpio_release(FLASH_CONFIG.spi_gpio);
}
static void prv_flas... | while (buffer_size--) {
*buffer = prv_flash_read_next_byte();
buffer++;
} |
prv_flash_end_cmd();
prv_disable_flash_spi_clock();
}
|
app_smartstrap_attribute_end_write(NULL, 0, false));
assert_result_invalid(app_smartstrap_attribute_end_write(NULL, 0, true));
assert_result_invalid(app_smartstrap_attribute_end_write(NULL, 100, false));
assert_result_invalid(app_smartstrap_attribute_end_write(NULL, 100, true));
assert_result_invalid(app_smarts... | (write_length2 == 0) | ;
// end the write request without sending anything
assert_result_invalid(app_smartstrap_attribute_end_write(attr, 0, false));
// start the write request again
write_buffer = NULL;
write_length = 0;
assert_result_ok(app_smartstrap_attribute_begin_write(attr, &write_buffer, &write_length));
cl_assert(wri... |
do_not_disturb_set_schedule_enabled(WeekdaySchedule, false) | ; // Clears overrides
active = do_not_disturb_is_active();
cl_assert(active == true);
// !Manual && Scheduled && Smart
do_not_disturb_set_manually_enabled(false);
do_not_disturb_set_schedule_enabled(WeekdaySchedule, true);
active = do_not_disturb_is_active();
cl_assert(active == true);
}
void test_do_no... | |
his function may be called from an ISR
if (s_input_enabled) {
return;
}
prv_lock();
if (s_sent_data) {
// wait for the TC flag to be set
uart_wait_for_tx_complete(ACCESSORY_UART);
// wait a little for the lines to settle down
const uint32_t us_to_wait = (1000000 / s_baudrate) * 2;
delay... | {
bool should_context_switch = false;
if (s_stream_cb && !s_send_history.has_data) {
s_did_send_byte = false;
if (s_stream_cb(s_stream_context)) {
// the callback MUST send a byte in order for this interrupt to trigger again
PBL_ASSERTN(s_did_send_byte);
} else {
// we're done sending
... |
// Commands
////////////////////////////////////////////////////////////////////
void command_accessory_power_set(const char *on) {
if (!strcmp(on, "on")) {
accessory_set_power(true);
} else if (!strcmp(on, "off")) {
accessory_set_power(false);
} else {
prompt_send_response("Usage: accessory power (... |
< NUMBER_ENTRIES; j++) {
if (manual && (j % 10 == 0)) {
cl_must_pass(settings_file_compact(&file));
}
settings_file_get(&file, (uint8_t *)&j, sizeof(uint32_t),
(uint8_t *)&value, sizeof(uint32_t));
value += 1;
set_and_verify(&file, (uint8_t *)&j, sizeof(uin... | prv_print_stats(&file) | ;
int i = j % 255;
snprintf((char *)key, sizeof(key), "k%03d", i);
snprintf((char *)val, sizeof(val), "v%03d", i);
printf("Iteration %d key %s val %s\n", i, key, val);
set_and_verify(&file, key, key_len, val, val_len);
// delete the first iteration
if (j < 255) {
settings_file_delete(&... |
mple_dialog->dialog;
// Ownership of icon is taken over by KinoLayer in dialog_init_icon_layer() call below
KinoReel *icon = dialog_create_icon(dialog);
const GSize icon_size = icon ? kino_reel_get_size(icon) : GSizeZero;
GRect frame = window->layer.bounds;
// Status Layer
if (dialog->show_status_layer) ... | if (simple_dialog) {
simple_dialog_init(simple_dialog, dialog_name);
} |
return simple_dialog;
}
void simple_dialog_set_buttons_enabled(SimpleDialog *simple_dialog, bool enabled) {
simple_dialog->buttons_disabled = !enabled;
}
void simple_dialog_set_icon_animated(SimpleDialog *simple_dialog, bool animated) {
// This cannot be set after the window has been loaded
PBL_ASSERTN(!wind... |
utput));
cl_assert_equal_i(output, cases[i].expected_output);
ASSERT_JS_ERROR(error_value, NULL);
jerry_release_value(v);
}
}
void test_rocky_api_util_args__numbers(void) {
uint8_t u8;
uint16_t u16;
uint32_t u32;
uint64_t u64;
int8_t s8;
int16_t s16;
int32_t s32;
int64_t s64;
double d;
... | (s32, (int32_t)c->s32) | ;
cl_assert_equal_i(s64, (int64_t)c->s64);
cl_assert_equal_d(d, (double)c->d);
}
JERRY_ARGS_RELEASE();
}
}
void test_rocky_api_util_args__number_type_mismatch(void) {
jerry_value_t mismatch_args[] = {
jerry_create_null(),
jerry_create_string((const jerry_char_t *)"one"),
jerry_creat... |
(ActivityMetricHeartRateRawUpdatedTimeUTC, 1, &last_update_utc);
cl_assert(last_update_utc >= rtc_get_time() - 1);
cl_assert(last_update_utc <= rtc_get_time());
// Should still be sampling every 1 second
cl_assert_equal_i(s_hrm_manager_update_interval, 1);
// Tick one more second, should trigger slow sampli... | rtc_get_time() | - 1);
cl_assert(last_update_utc <= rtc_get_time());
}
static uint32_t s_num_hr_events;
static PebbleHealthEvent s_last_hr_event;
static void prv_fake_hr_event_handler(PebbleEvent *e) {
s_num_hr_events++;
s_last_hr_event = e->health_event;
}
// ------------------------------------------------------------------... |
0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
// 315: Local time: 02:29:00 AM
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 5},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
{ 0, 0x45, 0},
... | { 0, 0x1c, 0},
{ 0, 0x1c, 0},
{ 0, 0x17, 26},
{ 0, 0x15, 0},
{ 0, 0x15, 0},
{ 0, 0x15, 0},
{ 0, 0x46, 19},
{ 0, 0x46, 24},
{ 0, 0x24, 0},
{ 0, 0x24, 0},
{ 0, 0x24, 0},
{ 0, 0x24, 0},
// 480: Local time: 05:15:00 AM
{ 0, 0x24, 0},
{ 0, 0x24, 0},
{ 0, 0x24, ... |
// ----------------------------------------------------------------
// Sample captured at: 2015-08-22 19:57:00 local, 2015-08-23 02:57:00 GMT
// Accroding to misfit:
// total sleep: 374 min
// deep: 200 min
// light: 174 min
// 7:57pm awake (220 min)
// 11:36pm light (5 min)
// ...
// 5;54am awake
AlgDlsMin... |
----------------------------------------------------------------
// fill a buffer, return it's CRC32
static uint32_t prv_get_random_buffer(uint8_t **buf, unsigned int size) {
uint8_t *temp = calloc(size, sizeof(uint8_t));
for (unsigned int i = 0; i < size; i++) {
temp[i] = (uint8_t)(rand() % 10);
}
*buf =... | (i, DATA_LOGGING_UINT, item_size, false) | ;
cl_assert(logging_sessions[i]);
fake_system_task_callbacks_invoke_pending();
}
// Log Consume
for (int i = 0; i < 10; i++) {
prv_log_consume_random(logging_sessions[i], item_size, rand() % 12345);
}
}
// ----------------------------------------------------------------------------------------
voi... |
alytics.h"
#include "stubs_events.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_hexdump.h"
#include "stubs_passert.h"
#include "stubs_prompt.h"
#include "stubs_task_watchdog.h"
#include "stubs_pebble_tasks.h"
#include "stubs_sleep.h"
static EventServiceInfo *s_event_info;
void event_service_cl... | weather_service_create_default_forecast() | |
ule);
alarm_set_kind(id, ALARM_KIND_WEEKENDS);
prv_assert_alarm_config(id, 3, 14, false, ALARM_KIND_WEEKENDS, s_weekend_schedule);
bool custom_schedule1[7] = {true, false, true, false, false, true, true};
id = alarm_create(&(AlarmInfo) { .hour = 4, .minute = 14, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &cu... | (schedule_4, alarm_day_text_4) | ;
cl_assert_equal_s(alarm_day_text_4, "Tuesdays");
bool schedule_5[7] = {false, false, false, true, false, false, false};
char alarm_day_text_5[32] = {0};
alarm_get_string_for_custom(schedule_5, alarm_day_text_5);
cl_assert_equal_s(alarm_day_text_5, "Wednesdays");
bool schedule_6[7] = {false, false, false... |
/*
* 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... | (e.app_cache_event.install_id, app1.id) | ;
cl_assert_equal_i(S_SUCCESS, app_cache_remove_entry(app3.id));
e = fake_event_get_last();
cl_assert_equal_i(e.type, PEBBLE_APP_CACHE_EVENT);
cl_assert_equal_i(e.app_cache_event.cache_event_type, PebbleAppCacheEvent_Removed);
cl_assert_equal_i(e.app_cache_event.install_id, app3.id);
cl_assert_equal_i(fake... |
.gpio = GPIOA,
.gpio_pin = GPIO_Pin_1,
},
};
static const VoltageMonitorDevice VOLTAGE_MONITOR_TEMPERATURE_DEVICE = {
.adc = ADC1,
.adc_channel = ADC_Channel_TempSensor,
.clock_ctrl = RCC_APB2Periph_ADC1,
// .input not applicable
};
VoltageMonitorDevice * const VOLTAGE_MONITOR_ALS = &VOLTAGE_MONITOR_... | (VOLTAGE_MONITOR_ALS) | ;
voltage_monitor_device_init(VOLTAGE_MONITOR_BATTERY);
}
|
TransportDestinationSystem);
cl_assert_equal_b(comm_session_is_valid(session), true);
// Expect assert when Transport didn't clean up after itself:
cl_assert_passert(comm_session_deinit());
comm_session_close(session, CommSessionCloseReason_UnderlyingDisconnection);
}
void test_... | comm_session_close(session, CommSessionCloseReason_UnderlyingDisconnection) | ;
}
void test_session__reset_valid_session(void) {
Transport *transport = (Transport *) TransportID1;
CommSession *session = comm_session_open(transport, &s_transport_imp,
TransportDestinationSystem);
cl_assert_equal_b(comm_session_is_valid(session), true);
cl_assert_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(s_num_timeline_removes, 3) | ;
cl_assert_equal_i(s_last_timeline_item_added->header.timestamp, rtc_get_time());
}
void test_alarm_smart__trigger_30_min_early_vmc(void) {
AlarmId id;
id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_EVERYDAY, .is_smart = true });
prv_assert_alarm_config(id, 10, 30, false, ALARM_... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(mfg_info_get_watch_color(), 0) | |
n_aa(&context, GPoint(50, 50), 10, SW_ODD));
setup_test(&context, false, SW_ODD, GColorBlack, GColorBlack, false);
graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4);
ASSERT_CALLED(prv_draw_round_rect_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_ODD));
}
void test_graphics_context_${BIT_DEPTH_NAME... | GPoint(50, 50) | |
/*
* 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_ctx, fb, context_init_mode) | ;
framebuffer_clear(fb);
// Setup resources
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next */);
resource_init();
}
voi... |
lude "util/hash.h"
#include "util/math.h"
#include "util/size.h"
#include "clar.h"
#include <stdio.h>
static GContext s_ctx;
// Fakes
/////////////////////
#include "fake_content_indicator.h"
#include "fake_spi_flash.h"
#include "fixtures/load_test_resources.h"
GContext *graphics_context_get_current_context(void)... | {
const char* tutorial_msg = "Remova rapidamente todas as notificações ao segurar o botão Select "
"durante 2 segundos a partir de qualquer notificação.";
ExpandableDialog *expandable_dialog = expandable_dialog_create_with_params(
"Dismiss First Use", RESOURCE_ID_QUICK_DISMISS, tut... | |
/*
* 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... | profiler_node_get_last_cycles(node) | ;
}
uint32_t profiler_cycles_to_us(uint32_t cycles) {
RCC_ClocksTypeDef clocks;
RCC_GetClocksFreq(&clocks);
uint32_t mhz = clocks.HCLK_Frequency / 1000000;
return cycles / mhz;
}
uint32_t profiler_node_get_total_us(ProfilerNode *node) {
return profiler_cycles_to_us(node->total);
}
uint32_t profiler_node_ge... |
rv_draw_rect_stroked(&context, &GRect(10, 20, 40, 10), SW_EVEN));
setup_test(&context, false, SW_EVEN, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10);
ASSERT_CALLED(graphics_circle_draw_stroked_non_aa(&context, GPoint(50, 50), 10, SW_EVEN));
setup_test(&context, false, SW... | graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4) | ;
#if PBL_COLOR
ASSERT_CALLED(prv_draw_round_rect_aa_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_EVEN));
#else
ASSERT_CALLED(prv_draw_round_rect_stroked(&context, &GRect(20, 80, 40, 10), 4, SW_EVEN));
#endif
}
void test_graphics_context_${BIT_DEPTH_NAME}__draw_antialiased_stroke_width_odd(void) {
// Stroke w... |
seconds
{ 928, -16, -280},
{ 1320, -96, -216},
{ 1816, 40, -8},
{ 2528, 376, 16},
{ 2104, 536, -48},
{ 1560, 792, -176},
{ 1408, 976, -136},
{ 1216, 576, 56},
{ 1168, 392, 16},
{ 880, 224, 24},
{ 736, 224, 8},
{ 664, 240, 8},
{ 704, 328, -80},
{ 808, 392, -104},
... | { 1048, 96, -296},
{ 1288, 176, -392},
{ 1176, 320, -152},
{ 1304, 144, -160},
{ 1648, 232, -144},
{ 1600, 488, -136},
// 8 seconds
{ 1072, 432, -96},
{ 1056, 288, -56},
{ 1136, 232, -24},
{ 1200, 176, 8},
{ 1096, 176, 16},
{ 1000, 176, 16},
{ 976, 168, 40},
{... | |
buted under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "services/common/regular_timer.h"
#include "os/mutex.h"
#include... | rtc_get_time_ms(&seconds, &milliseconds) | |
");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOU... | (&ctx, fb) | ;
layer_set_update_proc(&layer, &across_ny_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_line_across_ny_origin_layer")));
}
void test_graphics_draw_line__offset_layer(void) {
GContext ctx;
Layer layer;
test_graphics_cont... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | graphics_context_set_fill_color(ctx, command->fill_color) | ;
gpath_fill_precise_internal(ctx, command->precise_points, command->num_precise_points);
}
if ((command->stroke_color.a != 0) && (command->stroke_width > 0)) {
graphics_context_set_stroke_color(ctx, command->stroke_color);
graphics_context_set_stroke_width(ctx, command->stroke_width);
gpath_draw_ou... |
ORIGIN_RECT_CLIP_XY, true, 11);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY, RADIUS_DEFAULT);
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_aa_sw11_clip_xy.${BIT_DEPTH_NAME}.pbi"));... | gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi") | );
#endif
// SW = 5
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 5);
graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r4_sw5_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb,... |
Info
static void prv_call_ble_bonding_change_handlers(BTBondingID bonding, BtPersistBondingOp op) {
gap_le_connect_handle_bonding_change(bonding, op);
kernel_le_client_handle_bonding_change(bonding, op);
bt_pairability_update_due_to_bonding_change();
}
static BTBondingID prv_bt_persistent_storage_store_ble_pair... | if (!bt_ctl_is_bluetooth_running()) {
return;
} |
BleBonding bonding = {
.is_gateway = true,
};
if (!shared_prf_storage_get_ble_pairing_data(&bonding.pairing_info, NULL, NULL, NULL)) {
return;
}
bt_driver_handle_host_removed_bonding(&bonding);
}
void bt_persistent_storage_delete_ble_pairing_by_id(BTBondingID bonding) {
prv_remove_ble_bonding_from... |
>node);
}
return evt_ctx;
}
static BTErrno prv_read(uintptr_t obj_ref, GAPLEClient client,
HandleAndConnectionGetter handle_getter,
PebbleBLEGATTClientEventType subtype) {
BTErrno ret_val = BTErrnoOK;
bt_lock();
{
GAPLEConnection *connection;
const uin... | bt_unlock() | ;
return ret_val;
}
BTErrno gatt_client_op_write_descriptor(BLEDescriptor descriptor,
const uint8_t *value,
size_t value_length,
GAPLEClient client) {
return prv_write(descriptor, value, value_le... |
.h"
#include "applib/ui/window_private.h"
#include "util/size.h"
#include <stdio.h>
// Helper Functions
////////////////////////////////////
#include "test_graphics.h"
#include "../graphics/util.h"
#if (SCREEN_COLOR_DEPTH_BITS == 1)
#include "1bit/test_framebuffer.h"
#elif (SCREEN_COLOR_DEPTH_BITS == 8)
#include "8... | cl_assert_equal_i(fread(png_data, 1, file_size, fp), file_size) | |
true;
}
}
}
bool pmic_power_off(void) {
bool ret = prv_write_register(PmicRegisters_PWR_CFG, 0xB2);
if (ret) {
// Goodbye cruel world. The PMIC should be removing our power at any time now.
while(1);
__builtin_unreachable();
}
return false;
}
static bool prv_set_mon_config_register(uint8... | prv_read_register(PmicRegisters_STATUSB, &status_b) | |
/*
* 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... | (&data->alarm_type_menu->window) | ) {
app_window_stack_remove(&data->alarm_type_menu->window, false);
}
}
static void prv_call_complete_cancelled_if_no_alarm(AlarmEditorData *data) {
if (data->alarm_id == ALARM_INVALID_ID && data->complete_callback) {
data->complete_callback(CANCELLED, data->alarm_id, data->callback_context);
}
}
static... |
/*
* 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... | (gsize_equal(¬_chosen_icon_bounds, &chosen_icon_bounds)) | ;
GRect icon_frame = { .size = chosen_icon_bounds };
grect_align(&icon_frame, cell_layer_bounds, GAlignRight, false);
const OptionMenuStyle * const style = prv_get_style();
icon_frame.origin.x -= style->right_icon_spacing;
const GBitmap *const icon =
is_chosen ? &option_menu->chosen_image : &option_me... |
},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 0, -1008},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1008},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
... | { 40, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 40, 8, -1000},
{... |
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 0, -1000},
{ 48, 8, -1000},
{ 48, 8, -1000},
{ 48, 0, -1008},
{ 48, 8, -1000},
{ 48, 8, -1000},
... |
_data->call_status_text_layer.layer, false);
layer_add_child(&s_phone_ui_data->core_ui_container,
&s_phone_ui_data->call_status_text_layer.layer);
// Shrink the bounds but not the frame size to allow for centering when action bar removed
s_phone_ui_data->call_status_text_layer.layer.bounds.size.... | (DISCONNECTED) | ;
} else {
prv_set_status_text(DECLINED);
}
}
prv_window_pop_with_delay(CALL_END_DELAY_MS);
}
void phone_ui_handle_call_hide(void) {
// Just pop the window - it'll handle all the cleanup
prv_window_pop();
}
void phone_ui_handle_caller_id(PebblePhoneCaller *caller) {
if (!s_phone_ui_data) {
... |
We need to enable other applib modules like scroll_layer, menu_layer, etc. which are
// compiled to use the 3.0 animation API to work with 2.0 apps.
return (const AnimationImplementation*)((AnimationLegacy2 *)animation_h)->implementation;
}
AnimationPrivate *animation = prv_find_animation_by_handle(NULL, ... | prv_animation_state_get(PebbleTask_Current) | |
ioning
.paging.origin_on_screen = {0, 0},
},
};
render_steps(&layout, RenderMoveTextBox, DELTA, DISP_ROWS, NULL);
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_text_flow__with_origin_non_zero(void) {
TextLayoutExtended layout = {
.flow_data = {
.perimeter... | (gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE)) | |
format, time_t timestamp) {
struct tm time_tm;
localtime_r(×tamp, &time_tm);
const size_t ret_val = strftime(buffer, buf_size, i18n_get(format, buffer), &time_tm);
i18n_free(format, buffer);
return ret_val;
}
size_t clock_get_time_number(char *number_buffer, size_t number_buffer_size, time_t timestamp) ... | (word_buffer, word_buffer_size, current_day) | |
720, 224},
{ -480, 728, 216},
{ -464, 728, 216},
{ -456, 728, 216},
{ -464, 728, 224},
{ -472, 720, 224},
{ -472, 728, 208},
{ -464, 728, 216},
{ -456, 728, 224},
{ -464, 728, 224},
{ -472, 720, 224},
{ -464, 728, 216},
{ -472, 736, 208},
{ -472, 720, 224},
{ -472... | { -472, 808, 120},
{ -352, 696, 256},
{ -472, 832, 216},
// 171 seconds
{ -400, 712, 184},
{ -472, 752, 184},
{ -448, 752, 208},
{ -424, 752, 208},
{ -424, 768, 192},
{ -432, 752, 200},
{ -432, 752, 208},
{ -432, 752, 208},
{ -440, 752, 200},
{ -432, 752, 200},
... |
{ -440, 752, 200},
{ -440, 752, 200},
{ -440, 752, 200},
{ -432, 752, 200},
{ -440, 752, 208},
{ -440, 752, 200},
{ -440, 752, 200},
{ -440, 752, 200},
{ -440, 752, 200},
{ -440, 752, 200},
{ -440, 752, 200},
// 174 seconds
{ -440, 752, 200},
{ -440, 752, 200},
... |
return false;
}
if (endpoint_id != TIMELINE_ACTION_ENDPOINT) {
return false;
}
cl_assert_equal_m(s_expected_send_data, data, length);
s_sent_action = true;
return true;
}
static void prv_support_sms_replies(void) {
// Store the preference in our DB
char *key = "com.apple.MobileSMS";
int key_... | cl_assert_equal_i(response_action->attr_list.num_attributes, 2) | ;
cl_assert_equal_i(response_action->attr_list.attributes[0].id, AttributeIdTitle);
cl_assert_equal_s(response_action->attr_list.attributes[0].cstring, "Reply");
cl_assert_equal_i(response_action->attr_list.attributes[1].id, AttributeIdEmojiSupported);
cl_assert_equal_i(response_action->attr_list.attributes[1].... |
/*
* 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_pairability_timer_info) | ) {
// If this function is called multiple times before the timer is unscheduled, limit to calling
// "use" only once:
bt_pairability_use_ble();
}
// Always reschedule, even if the duration is shorter than the one that might already be
// scheduled:
regular_timer_add_multisecond_callback(&s_pairabil... |
/*
* 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(s_pending_did_write.attribute == attribute) | ;
s_pending_did_write.active = false;
}
static void prv_prepare_for_notified(SmartstrapAttribute *attribute) {
cl_assert(!s_pending_notified.active);
s_pending_notified = (PendingInfo) {
.active = true,
.attribute = attribute
};
}
static void prv_notified_handler(SmartstrapAttribute *attribute) {
cl... |
.flags = 0,
.layout = LayoutIdTest,
}
}
};
// all day item
static TimelineItem s_all_day_items[] = {
{
.header = {
.id = {0x01},
.parent_id = {0},
.timestamp = 1421020800, // midnight jan 12, 2015 UTC
.duration = MINUTES_PER_DAY,
.type = TimelineItemTyp... | (&iterator) | );
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[2].header.id));
// check fifth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.header.id, &s_items[1].header.id));
// check sixth
cl_assert(iter_next(&iterator));
cl_assert(uuid_equal(&state.pin.head... |
me out of STOP mode (which is
// at least once/second) since the timer peripheral will not have been
// incremented
task_watchdog_step_elapsed_time_ms((ticks_elapsed * 1000) / RTC_TICKS_HZ);
s_analytics_device_stop_ticks += ticks_elapsed;
s_analytics_app_stop_ticks += ticks_elapsed;
}... | mcu_cycles_to_milliseconds(s_analytics_device_sleep_cpu_cycles) | ;
uint32_t now_ticks = rtc_get_ticks();
uint32_t running_ms =
ticks_to_milliseconds(now_ticks - s_last_ticks) - stop_ms - sleep_ms;
uint32_t tot_time = running_ms + sleep_ms + stop_ms;
char buf[80];
dbgserial_putstr_fmt(buf, sizeof(buf), "Run: %"PRIu32" ms (%"PRIu32" %%)",
ru... |
/*
* 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... | pebble_task_get_current() | ;
AccelServiceState *state = (AccelServiceState *)accel_service_private_get_session(task);
PBL_ASSERTN(state->shake_handler != NULL);
if (task == PebbleTask_Worker || task == PebbleTask_App) {
sys_analytics_inc(ANALYTICS_APP_METRIC_ACCEL_SHAKE_COUNT, AnalyticsClient_CurrentTask);
}
state->shake_handler(e... |
}
void test_app_db__cleanup(void) {
//nada
}
// Tests
////////////////////////////////////////////////////////////////
void test_app_db__basic_test(void) {
// confirm all three are there
cl_assert(app_db_get_len((uint8_t*)&app1.uuid, sizeof(Uuid)) > 0);
cl_assert(app_db_get_len((uint8_t*)&app2.uuid, sizeof(... | app_db_insert((uint8_t*)&app1.uuid, sizeof(Uuid), (uint8_t*)&app1,
sizeof(AppDBEntry)) | );
cl_assert_equal_i(S_SUCCESS, app_db_insert((uint8_t*)&app1.uuid, sizeof(Uuid), (uint8_t*)&app1,
sizeof(AppDBEntry)));
cl_assert(app_db_check_next_unique_id() == 4);
// add two more duplicates of a different app. Confirm it only increments by 1.
cl_assert_equal_i(S_SUCCESS, app_db_insert((uint8_t*)&app... |
xt;
// mocks
static MockCallRecordings s_graphics_context_set_fill_color;
void graphics_context_set_fill_color(GContext* ctx, GColor color) {
record_mock_call(s_graphics_context_set_fill_color) {
.ctx = ctx, .color = color,
};
ctx->draw_state.fill_color = color;
}
static MockCallRecordings s_graphics_contex... | {
record_mock_call(s_graphics_text_layout_get_max_used_size){
.max_used_size.font = font,
.max_used_size.box = box,
.max_used_size.overflow_mode = overflow_mode,
.max_used_size.alignment = alignment,
};
strncpy(s_graphics_text_layout_get_max_used_size.last_call.max_used_size.text,
text, ... |
void test_rocky_api_graphics__initialize(void) {
fake_app_timer_init();
rocky_runtime_context_init();
jerry_init(JERRY_INIT_EMPTY);
s_app_window_stack_get_top_window = (Window){};
s_context = (GContext){};
s_app_state_get_graphics_context = &s_context;
s_app_event_loop_callback = NULL;
s_graphics_co... |
csMetric metric, int64_t value, AnalyticsClient client) {
analytics_set_for_uuid(metric, value, analytics_uuid_for_client(client));
}
void analytics_max(AnalyticsMetric metric, int64_t val, AnalyticsClient client) {
const Uuid *uuid = analytics_uuid_for_client(client);
analytics_storage_take_lock();
Analytic... | (LOG_LEVEL_DEBUG, "Analytics stopwatch for metric %d already started!", metric) | ;
goto unlock;
}
AnalyticsStopwatchNode *stopwatch = kernel_malloc_check(sizeof(*stopwatch));
*stopwatch = (AnalyticsStopwatchNode) {
.metric = metric,
.starting_ticks = rtc_get_ticks(),
.count_per_sec = count_per_sec,
.client = client,
};
list_init(&stopwatch->node);
s_stopwatch_list ... |
app_inbox_create_and_register_drop_handler_not_permitted(void) {
// The syscall_failed() fake will trigger passert:
cl_assert_passert(app_inbox_create_and_register(BUFFER_SIZE, 1,
test_message_handler,
NOT_PERMITTED_... | (AppInboxServiceTagUnitTest) | );
}
void test_app_inbox__app_inbox_service_begin_already_being_written(void) {
prv_create_test_inbox();
cl_assert_equal_b(true, app_inbox_service_begin(AppInboxServiceTagUnitTest,
BUFFER_SIZE, s_writer));
cl_assert_equal_b(true, app_inbox_service_is_being_writte... |
utLayer *)timeline_layout, mode);
}
}
}
///////////////////////////////////////////////////////////
// Drawing functions
///////////////////////////////////////////////////////////
// An animation that moves a layer from an initial position to its final position
static Animation *prv_create_layout_up_down_anima... | ((Layer *)&timeline_layer->day_separator, &frame) | |
CAPABILITY_HAS_BUILTIN_HRM
case TimelineItemActionTypeBLEHRMStopSharing:
prv_invoke_ble_hrm_stop_sharing_action(action_menu, pin);
return NULL;
#else
case TimelineItemActionTypeBLEHRMStopSharing:
break;
#endif
}
PBL_LOG(LOG_LEVEL_ERROR, "Unsupported action type %d", action->type);
if (... | action_menu_level_create(num_items) | ;
level->parent_level = parent_level;
return level;
}
static ActionMenuLevel *prv_create_template_level_from_action(ActionMenuLevel *parent_level,
TimelineItemAction *action,
void *i18n_owner... |
eneration script.
AppInstallId app_get_install_id_for_uuid_from_registry(const Uuid *uuid) {
for (uint16_t i = 0; i < ARRAY_LENGTH(APP_RECORDS); i++) {
const AppRegistryEntry *reg_entry = &APP_RECORDS[i];
if (reg_entry->type == AppInstallStorageFw) {
const PebbleProcessMd *md = reg_entry->md_fn();
... | {
PBL_ASSERTN(callback_node->node.next == NULL);
PBL_ASSERTN(callback_node->node.prev == NULL);
PBL_ASSERTN(s_head_callback_node_list != &callback_node->node);
PBL_ASSERTN(callback_node->callbacks != NULL);
callback_node->registered_by = pebble_task_get_current();
s_head_callback_node_list = list_prepend(... |
void app_install_deregister_callback(struct AppInstallCallbackNode *callback_node) {
PBL_ASSERTN(callback_node->node.next != NULL
|| callback_node->node.prev != NULL
|| s_head_callback_node_list == &callback_node->node);
list_remove(&callback_node->node, &(s_head_callback_node_list), N... |
s,
&context.completed, 30 /*timeout_sec*/);
if (success) {
*num_records = context.num_records;
*data_bytes = context.data_bytes;
*minutes = context.minutes;
} else {
*num_records = 0;
*data_bytes = 0;
*minutes = 0;
}
return success;
}
// ----------... | {
ActivitySettingsValueHistory step_history = {
.utc_sec = rtc_get_time(),
.values = {
0, // This ends up overwritten anyway by the current sleep value
1000,
750,
1250,
500,
2000,
3000
}
};
prv_write_metric_history(ActivitySettingsKeyStepCountHistory, &step_h... |
// ------------------------------------------------------------------------------------------------
void activity_test_set_sleep_history() {
ActivitySettingsValueHistory sleep_history = {
.utc_sec = rtc_get_time(),
.values = {
0, // This ends up overwritten anyway by the current sleep value
400... |
expandable_dialog_get_dialog(expandable_dialog) | ;
dialog_set_timeout(dialog, DIALOG_TIMEOUT_INFINITE /* no timeout */);
window_set_on_screen(&dialog->window, true, true);
for (uint32_t i = 0; i < num_times_to_scroll_down; i++) {
scroll_layer_scroll(&expandable_dialog->scroll_layer, ScrollDirectionDown,
false /* animated */);
}
... | |
sert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, seq), 0);
// The stopped handler for A should fire before the started handler for B
cl_assert(prv_last_handler_entry(&s_stopped_handler_calls, a)->fire_order
< prv_last_handler_entry(&s_started_handler_calls, b)->fire_order);
// Just ... | (prv_count_animations(), 0) | ;
#endif
}
// --------------------------------------------------------------------------------------
// Test a seeking in a basic sequence animation
void test_animation__simple_sequence_set_elapsed(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 500;
const int duration_c ... |
r_function(script);
cl_assert(*s_log_internal__expected == NULL);
}
void test_rocky_api_util__call_throw_string(void) {
s_log_internal__expected = (const char *[]){
"Unhandled exception",
" "ERROR_STRING,
NULL
};
const char *script = "var "FUNC_NAME" = function() { throw '"ERROR_STRING"'; };";
... | {
#ifdef EMSCRIPTEN
printf("Skipping test %s", __FUNCTION__);
#else
int fail_count = 0;
for(int y = 1950; y < 2050; y++) {
for(int m = 0; m < 12; m++) {
for (int d = 1; d < 32; d++) {
const ecma_number_t result = ecma_date_make_day(y, m, d);
if (isnan(result)) {
printf("failed ... |
void test_rocky_api_util__create_date_tm(void) {
const time_t cur_time = 1458250851; // Thu Mar 17 21:40:51 2016 UTC
// Thu Mar 17 14:40:51 2016 PDT
const uint16_t cur_millis = 123;
fake_time_init(cur_time, cur_millis);
struct tm tick_time = {
.tm_sec = 28,
.tm_... |
clip_box->origin.x;
const int16_t max_valid_x = grect_get_max_x(clip_box) - 1;
// x1/x2 clipping and verification happens in raw drawing function to preserve gradients
ctx->draw_state.draw_implementation->assign_horizontal_line_delta(ctx, y, x1, x2,
... | grect_get_max_y(&bitmap->bounds) | - 1;
for (int16_t y = min_y; y <= max_y; y++) {
const GBitmapDataRowInfo row_info = gbitmap_get_data_row_info(bitmap, y);
const int16_t min_x = MAX(row_info.min_x, bitmap->bounds.origin.x);
const int16_t max_x = MIN(row_info.max_x, grect_get_max_x(&bitmap->bounds) - 1);
const int16_t num_pix_data_row... |
e_common.h"
#include "dbg_swdiag.h"
#include "gapc.h"
#include "ke_timer.h"
#include "llc.h"
#include "llc_data.h"
#include "llc_util.h"
#include "lld_data.h"
#include "llm_util.h"
#include <util/size.h>
#include <stdint.h>
#include <string.h>
#define IS_AE_CHIP ((dg_configBLACK_ORCA_IC_REV == BLACK_ORCA_IC_REV_A) &... | (conhdl, LE_LENGTH_REQ_PEND) | ;
// Get the TX buffer to be used
struct co_buf_tx_desc *txdesc = co_buf_tx_desc_get(LLC_LE_CNTL_PKT_BASE_IDX + conhdl);
struct llcp_unknown_rsp *data = (struct llcp_unknown_rsp *)co_buf_tx_buffer_get(txdesc);
// Build the Unknown Response PDU
data->opcode = LL_UNKNOWN_RSP;
data->unk_type = LL_LENGTH_REQ... |
/*
* 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_ALWAYS, "Dialog: Rebooted due to Unrecognized Reason") | ;
break;
}
clear:
reboot_reason_clear();
}
|
ayer, callback_context, &callbacks);
}
void menu_layer_set_click_config_onto_window(MenuLayer *menu_layer, struct Window *window) {
// Delegate this directly to the scroll layer:
scroll_layer_set_click_config_onto_window(&menu_layer->scroll_layer, window);
}
//! @returns 0 if A and B are equal, 1 if A has a highe... | prv_setup_selection_animation(menu_layer, up) | ;
} else {
if (change_ongoing_animation) {
prv_cancel_selection_animation(menu_layer);
}
// Move selection inverter layer:
const int16_t w = menu_layer->scroll_layer.layer.frame.size.w;
const GSize size = GSize(w, menu_layer->selection.h);
menu_layer->inverter.layer.bounds = (GRect) {
... |
list_remove((ListNode*) old_node, (ListNode**) loaded_list, NULL) | ;
prv_unload_loaded_notification(old_node);
}
// load the notification
TimelineItem notification;
if (!notification_storage_get(&node->id, ¬ification)) {
return NULL;
}
// track the loaded notification
loaded_node = app_malloc_check(sizeof(LoadedNotificationNode));
list_init((ListNode*) lo... | |
/*
* 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... | (ModalPriorityNotification) | ;
}
static void prv_push_result_dialog(ActionToggleContext *ctx) {
ActionToggleDialogConfig config = {
.message = ctx->config.impl->result_messages[prv_get_toggled_state_index(ctx)],
};
prv_setup_state_config(ctx, &config, ActionToggleDialogType_Result);
SimpleDialog *simple_dialog = simple_dialog_create(c... |
State,
&s_sleep_pin_state, sizeof(s_sleep_pin_state));
prv_restore_state(file, ActivitySettingsKeyInsightNapSessionTime,
&s_nap_pin_state.last_triggered_utc,
sizeof(s_nap_pin_state.last_triggered_utc));
prv_restore_state(file, ActivitySettingsKey... | {
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_sleep_summary_notification(now_utc, total_seconds, total_seconds, i);
prv_push_sleep_summary_notificat... |
}
static void prv_test_push_rewards(void *unused) {
time_t now_utc = rtc_get_time();
if (activity_prefs_sleep_insights_are_enabled()) {
prv_push_reward(now_utc, &SLEEP_REWARD_NOTIF_CONFIG);
}
if (activity_prefs_activity_insights_are_enabled()) {
prv_push_reward(now_utc, &ACTIVITY_REWARD_NOTIF_CONFIG... |
/*
* 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_weather_db.settings_file) | ;
mutex_unlock(s_weather_db.mutex);
}
static bool prv_weather_db_for_each_cb(SettingsFile *file, SettingsRecordInfo *info,
void *context) {
if ((info->val_len == 0) || (info->key_len != sizeof(WeatherDBKey))) {
return true;
}
WeatherDBKey key;
info->get_key(file, &... |
ine_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(&success, "Foo ba... | cl_assert(line.width_px == 3 * HORIZ_ADVANCE_PX) | ;
// reset line
line = (Line) { 0 };
line.max_width_px = text_box_params.box.size.w;
line.height_px = text_box_params.box.size.h;
cl_assert(line_add_word(&s_ctx, &line, &word_iter_state.current, &text_box_params));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == 1 * HORIZ_ADVANCE_PX);
cl_... |
/*
* 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_ERROR,
"Invalid entry. Valid UT: %u, location length: %"PRIu16,
is_valid_entry_update_time, location_pstring_length);
return false;
} | |
xSemaphoreTake(s_dma_update_in_progress_semaphore, portMAX_DELAY) | ;
analytics_stopwatch_start(ANALYTICS_APP_METRIC_DISPLAY_WRITE_TIME, AnalyticsClient_App);
analytics_inc(ANALYTICS_DEVICE_METRIC_DISPLAY_UPDATES_PER_HOUR, AnalyticsClient_System);
prv_enable_display_spi_clock();
power_tracking_start(PowerSystemMcuDma1);
SPI_I2S_DMACmd(BOARD_CONFIG_DISPLAY.spi, SPI_I2S_DMAReq... | |
/*
* 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... | (full_name, ' ') | ;
// If there are no spaces, just use the whole thing and bail.
if (!space) {
strncpy(destination, full_name, length);
destination[length - 1] = '\0';
return;
}
// Copy the first name to the destination, as long as it fits.
size_t pos = MIN((size_t)(space - full_name), length - 1);
strncpy(desti... |
ding_rx_ack_count = 0;
} else { // we are sending a data packet
const uint32_t sn = client->out.next_data_sn;
prv_set_payload_size_for_sn(client, sn, payload_size);
if (client->out.ack_timeout_state == AckTimeoutState_Inactive) {
prv_reset_ack_timeout(client); // Enable timeout if we don't already h... | (client, true /* is_disconnected */, DeleteReason_DestroyCalled) | ;
client = next;
}
}
bt_unlock();
}
// -------------------------------------------------------------------------------------------------
// For Unit Testing
Transport *ppogatt_client_for_uuid(const Uuid *uuid) {
return (Transport *) prv_find_client_with_uuid(uuid);
}
TransportDestination ppogatt_get_... |
s->num_contacts = NUM_SEND_TEXT_CONTACTS;
for (int i = 0; i < NUM_SEND_TEXT_CONTACTS; ++i) {
prefs->contacts[i] = (SerializedSendTextContact) {
.is_fav = (i < (NUM_SEND_TEXT_CONTACTS/2)),
};
uuid_generate(&prefs->contacts[i].contact_uuid);
uuid_generate(&prefs->contacts[i].address_uuid);
}
... | cl_assert_equal_i(watch_app_prefs_db_insert(WEATHER_KEY, WEATHER_KEY_LEN, s_weather_prefs,
sizeof(s_weather_prefs)), S_SUCCESS) | ;
cl_assert_equal_i(watch_app_prefs_db_flush(), S_SUCCESS);
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(watch_app_prefs_db_get_len(SEND_TEXT_KEY, SEND_TEXT_KEY_LEN), 0);
}
void test_watch_app_prefs_db__get_send_text(void) {
const int data_len = sizeof(s_send_text_prefs);
cl_assert_equal_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... | cl_assert(resource_id != UINT32_MAX) | |
us);
prv_handle_ready_error(data);
break;
default:
WTF;
}
if (event->status != VoiceStatusSuccess) {
data->last_session_successful = false;
}
}
static bool prv_handle_dictation_success(VoiceUiData *data, PebbleVoiceServiceEvent *event) {
if (data->buffer_size == 0) {
// If buffer ... | _Static_assert(StateExiting < ARRAY_LENGTH(state_map), "The number of states has grown, but state"
"the simple state mapping has not been updated") | ;
PBL_ASSERTN(state < ARRAY_LENGTH(state_map));
return state_map[state];
}
static void prv_voice_event_handler(PebbleEvent *e, void *context) {
PebbleVoiceServiceEvent *event = (PebbleVoiceServiceEvent *) e;
VoiceUiData *data = context;
VoiceUiState simple_state = prv_get_simple_state(data->state);
VOICE... |
0)
#define BITS_BETWEEN(x, y) (BITS(y) & ~BITS(x-1))
// Yo dawg, I heard you like tests so I put tests in your tests so you can test
// your tests while you test!
void test_system_flash__bit_range_macros(void) {
cl_assert_equal_i(0b1, BITS(0));
cl_assert_equal_i(0b00011111, BITS(4));
cl_assert_equal_i(0b0011111... | (flash_written_flag[start + i] == false) | |
draw_background(menu_layer, ctx, &menu_layer->scroll_layer.layer, false);
}
MenuRenderIterator *render_iter = applib_type_malloc(MenuRenderIterator);
PBL_ASSERTN(render_iter);
if (menu_layer->center_focused) {
// in this mode, the selected row is always the best candidate for the cache
menu_layer->cac... | layer_deinit(&menu_layer->inverter.layer) | ;
scroll_layer_deinit(&menu_layer->scroll_layer);
}
void menu_layer_destroy(MenuLayer* menu_layer) {
if (menu_layer == NULL) {
return;
}
menu_layer_deinit(menu_layer);
applib_free(menu_layer);
}
Layer* menu_layer_get_layer(const MenuLayer *menu_layer) {
return &((MenuLayer *)menu_layer)->scroll_layer.... |
y) {
// Wrap-around source bitmap vertically
if (src_y >= src_end_y) {
src_y = src_begin_y;
}
const GBitmapDataRowInfo dest_row_info = gbitmap_get_data_row_info(dest_bitmap, dest_y);
uint8_t *dest = dest_row_info.data;
const int16_t dest_delta_begin_x = MAX(dest_row_info.min_x - dest_rect... | {
src_y = src_begin_y;
} |
const GBitmapDataRowInfo dest_row_info = gbitmap_get_data_row_info(dest_bitmap, dest_y);
uint8_t *dest = dest_row_info.data;
const int16_t dest_delta_begin_x = MAX(dest_row_info.min_x - dest_rect.origin.x, 0);
const int16_t dest_begin_x = dest_delta_begin_x ? dest_row_info.min_x : dest... |
*)align_str);
}
// we speed this up, e.g. by sorting and doing binary search if this ever becomes an issue
T_STATIC const RockyAPISystemFontDefinition s_font_definitions[] = {
{.js_name = "18px bold Gothic", .res_key = FONT_KEY_GOTHIC_18_BOLD},
{.js_name = "14px Gothic", .res_key = FONT_KEY_GOTHIC_14},
{.js_name... | jerry_acquire_value(result) | ;
}
void rocky_api_graphics_text_add_canvas_methods(jerry_value_t obj) {
rocky_add_function(obj, ROCKY_CONTEXT2D_FILLTEXT, prv_fill_text);
rocky_add_function(obj, ROCKY_CONTEXT2D_MEASURETEXT, prv_measure_text);
rocky_define_property(obj, ROCKY_CONTEXT2D_TEXTALIGN, prv_get_text_align, prv_set_text_align);
rocky... |
p();
__profiler_print_stats();
int64_t time_rendered = prv_time_64() - data->time_started;
APP_LOG(APP_LOG_LEVEL_INFO, "## %d frames rendered", (int)data->rendered_frames);
if (time_rendered) {
int frame_period = time_rendered/(int64_t)data->rendered_frames;
int fps = (int64_t)data->rendered_frames*10... | bitmap_layer_set_bitmap(data->topleft_layer, &s_fps_topleft_bitmap) | ;
layer_add_child(root_layer, (Layer *)data->topleft_layer);
const GRect menu_layer_rect =
GRect(navbar_width, 0, full_rect.size.w - navbar_width, full_rect.size.h);
data->action_list1 = menu_layer_create(menu_layer_rect);
menu_layer_set_callbacks(data->action_list1, data, (MenuLayerCallbacks){
.g... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.