prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | framebuffer_init(fb, &(GSize) {DISP_COLS, DISP_ROWS}) | ;
test_image_bw = get_gbitmap_from_pbi("test_rotated_bitmap_no_litter.Xbit.pbi");
cl_assert(test_image_bw != NULL);
test_image_color = get_gbitmap_from_pbi("test_rotated_bitmap_redstar.Xbit.pbi");
cl_assert(test_image_color != NULL);
}
void test_graphics_draw_rotated_bitmap__cleanup(void) {
free(fb);
if (... |
/*
* 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... | (session, remaining_length) | ;
PBL_ASSERTN(session->send_queue_head);
SessionSendQueueJob *job = session->send_queue_head;
while (job && remaining_length) {
const size_t job_length = job->impl->get_length(job);
const size_t consume_length = MIN(remaining_length, job_length);
job->impl->consume(job, consume_length);
SessionSe... |
(&connection->device);
} else {
PBL_LOG(LOG_LEVEL_ERROR, "PPoGatt: disconnect attempt failed, no connection for char 0x%x",
(int)characteristic);
#if !RELEASE
// Observed this path getting hit in PBL-43336, let's try to collect a core to look at the
// gatt service state
... | comm_session_send_queue_consume(client->session, num_bytes_acked) | ;
// If next_data_sn is before the Ack'd sn, the packet pending retransmission has just been
// Ack'd. We can determine whether or not a packet is pending retransmission by checking if the
// payload size for next_data_sn is not 0. This means the packet has been enqueued to get sent
if (prv_is_packet_w... |
t uint32_t now = animation_legacy2_get_ms_since_system_start();
while (animation) {
const int32_t rel_ms_running = serial_distance32(animation->abs_start_time_ms, now);
if (rel_ms_running < 0) {
// AnimationLegacy2s are ordered by abs_start_time_ms.
// We've reached an animation that should not ... | (animation->abs_start_time_ms == 0) | ; // can't set after animation has been added
animation->duration_ms = duration_ms;
}
void animation_legacy2_set_curve(AnimationLegacy2 *animation, AnimationCurve curve) {
PBL_ASSERTN(animation->abs_start_time_ms == 0); // can't set after animation has been added
PBL_ASSERTN(curve < AnimationCurveCustomFunction)... |
struct clar_error *last_error;
void (*local_cleanup)(void *);
void *local_cleanup_payload;
jmp_buf trampoline;
int trampoline_enabled;
} _clar;
struct clar_func {
const char *name;
void (*ptr)(void);
};
struct clar_suite {
int index;
const char *name;
struct clar_func initialize;
struct clar_fun... | ("Options:\n") | |
y_assign_vertical_line);
CHECK_EXPECTED_TEST_IMAGE(s_ctx);
};
void prv_blend_vertical_line_raw(GContext *ctx, int16_t x, int16_t y1, int16_t y2, GColor color);
void test_graphics_context_mask__apply_blend_vertical_line_raw(void) {
// FIXME PBL-34141: This test produces an incorrect image, see JIRA
prv_mask_appl... | graphics_context_mask_use(ctx, mask1) | );
// Should still be on default draw implementation
cl_assert_equal_p(ctx->draw_state.draw_implementation, &g_default_draw_implementation);
// Should have attached mask1 to GContext
cl_assert_equal_p(ctx->draw_state.draw_mask, mask1);
GDrawMask *mask2 = graphics_context_mask_create(ctx, true /* transparent ... |
F;
static const uint8_t FLASH_CMD_DEEP_SLEEP = 0xB9;
static const uint8_t FLASH_CMD_WAKE = 0xAB;
static const uint8_t FLASH_CMD_DUMMY = 0xA9;
static const struct {
SPI_TypeDef *const spi;
GPIO_TypeDef *const spi_gpio;
uint8_t scs_pin, sclk_pin, miso_pin, mosi_pin;
} FLASH_CONFIG = {
.spi = SPI1,
.spi_gpio = ... | prv_flash_send_and_receive_byte(FLASH_CMD_READ_STATUS_REG) | ;
uint8_t status_register = 0;
do {
if (cycles_to_wait-- < 1) {
break;
}
status_register = prv_flash_read_next_byte();
} while (status_register & 0x1);
prv_flash_end_cmd();
}
static void prv_flash_wait_for_write(void) {
prv_flash_start_cmd();
prv_flash_send_and_receive_byte(FLASH_CMD_R... |
the background task
static void prv_update_and_cleanup_struct_async(const void *data, size_t size, size_t offset) {
WriteEraseCBData *callback_data = kernel_malloc_check(sizeof(*callback_data) + size);
*callback_data = (WriteEraseCBData) {
.size = size,
.offset = offset,
};
memcpy(callback_data->patch,... | {
*pairing_info_out = (const SMPairingInfo) {};
pairing_info_out->local_encryption_info.ediv = ble_data->local_ediv;
pairing_info_out->local_encryption_info.div = ble_data->local_div;
pairing_info_out->remote_encryption_info.ltk = ble_data->ltk;
pairing_info_out->remote_encryption_info.rand = ble_da... | |
prv_write_flash_log_record_header(msg_length);
return (s_curr_state.log_start_addr);
}
bool flash_logging_write(const uint8_t *data_to_write, uint32_t flash_addr,
uint32_t read_length) {
if ((s_curr_state.bytes_remaining < read_length) || !s_flash_logging_enabled) {
return (false);
}
uint32_t addr ... | system_task_add_callback(prv_dump_log_system_cb, state) | ;
}
}
bool flash_dump_log_file(int generation, DumpLineCallback line_cb,
DumpCompletedCallback completed_cb) {
uint8_t log_file_id = generation_to_log_file_id(generation);
uint32_t log_start_addr;
int num_log_pages = prv_get_start_of_log_file(log_file_id, &log_start_addr);
PBL_LOG(... |
into a 1440 minute day. The BMR for
// the above user is 1859 kcalories per day, so we expect to get:
// 1859 * 1020/1440 = 1328 kcalories
activity_get_metric(ActivityMetricRestingKCalories, 1, &value);
const int k_bmr_cal_2 = 1859 * ACTIVITY_CALORIES_PER_KCAL;
cl_assert_equal_i(value, ROUND(k_bmr_cal_2 * ... | health_service_sum_today(HealthMetricSleepSeconds) | , 220 * SECONDS_PER_MINUTE);
activity_get_metric(ActivityMetricSleepRestfulSeconds, 1, &value);
cl_assert_equal_i(value, 100 * SECONDS_PER_MINUTE);
cl_assert_equal_i(health_service_sum_today(HealthMetricSleepRestfulSeconds),
100 * SECONDS_PER_MINUTE);
activity_get_metric(ActivityMetricSlee... |
st_name = "8bitTrns",
.expected_test_image_bitmap_format = GBitmapFormat8Bit,
.bitmap_create_func = prv_create_bitmap_from_png_file,
.need_to_destroy_bitmap = true,
},
#endif
};
#define COMPOSITE_TEST_IMAGE_SIZE_WIDTH (100)
#define COMPOSITE_TEST_OFFSET_X (COMPOSITE_TEST_IMAGE_SIZE_WIDTH / 2)
#define CO... | (GPoint(-25, 0)) | |
t_size), 0);
// Write + consume, so read index is at 2:
circular_buffer_write(&buffer, (uint8_t *)"0123", 4);
circular_buffer_consume(&buffer, 2);
// Write data that will be wrapped:
circular_buffer_write(&buffer, (uint8_t *)"456789", 6);
// Test copying the whole thing (providing buffer of 8 bytes):
m... | cl_assert_equal_i(memcmp(copy_out, "234567AB", 8), 0) | |
_window);
} else {
prv_handle_stop_button(active_window);
}
}
static void prv_set_pause_button(WorkoutActiveWindow *active_window) {
bool can_stop = active_window->workout_controller->stop != NULL;
if (can_stop || active_window->num_scrollable_metrics > 1) {
active_window->pause_button = BUTTON_ID_UP;
... | if (active_window->layout == WorkoutLayout_SingleMetric) {
// Only 1 metric to show. It can have the whole screen
GRect metric_bounds = base_layer_bounds;
layer_init(&active_window->top_metric_layer, &metric_bounds);
layer_set_update_proc(&active_window->top_metric_layer, prv_static_layer_update_proc);
... |
// Three metrics. Two static metrics above a scrollable metric
const int layer_height = 51;
GRect top_metric_bounds = base_layer_bounds;
top_metric_bounds.size.h = layer_height;
layer_init(&active_window->top_metric_layer, &top_metric_bounds);
layer_set_update_proc(&active_window->top_metric_la... |
, 416, -752},
{ 456, 424, -752},
{ 464, 432, -752},
{ 456, 416, -768},
{ 448, 448, -816},
{ 456, 336, -744},
{ 456, 360, -696},
{ 456, 336, -736},
{ 512, 536, -728},
{ 456, 360, -784},
{ 432, 368, -760},
{ 464, 472, -744},
{ 480, 392, -760},
{ 464, 416, -744},
{ 4... | // 13 seconds
{ 424, 264, -824},
{ 432, 424, -728},
{ 496, 520, -704},
{ 464, 432, -760},
{ 440, 376, -784},
{ 440, 408, -760},
{ 464, 424, -768},
{ 472, 456, -704},
{ 448, 360, -816},
{ 456, 456, -760},
{ 456, 384, -760},
{ 456, 408, -752},
{ 480, 464, -760},
... |
{ 464, 392, -768},
{ 456, 416, -768},
{ 456, 384, -760},
{ 472, 408, -768},
{ 456, 400, -760},
{ 456, 408, -760},
{ 456, 392, -776},
{ 456, 384, -776},
// 16 seconds
{ 480, 416, -752},
{ 456, 416, -760},
{ 456, 408, -760},
{ 448, 400, -776},
{ 456, 384, -784},
... |
s_tick_timer_service_subscribe.last_call.tick_units);
EXECUTE_SCRIPT(
"var hourHandler = function() {};\n"
"_rocky.on('hourchange', hourHandler);\n"
);
cl_assert_equal_b(false, rocky_global_has_event_handlers("secondchange"));
cl_assert_equal_b(false, rocky_global_has_event_handlers("minu... | ASSERT_JS_GLOBAL_EQUALS_I("s", 6) | ;
ASSERT_JS_GLOBAL_EQUALS_I("m", 5);
ASSERT_JS_GLOBAL_EQUALS_I("h", 4);
ASSERT_JS_GLOBAL_EQUALS_I("d", 3);
}
void test_rocky_api_tickservice__event_types(void) {
rocky_global_init(s_api);
EXECUTE_SCRIPT(
"var s = null;\n"
"var m = null;\n"
"var h = null;\n"
"var d = null;\n"
"_rocky.on('... |
on *, void *) = {
NULL,
prv_create_template_level_from_action,
prv_create_emoji_level_from_action,
};
unsigned int item = 0;
for (ReplyOption reply = 0; reply < ReplyOptionCount; reply++) {
if (!prv_is_reply_option_supported(reply, action)) {
continue;
}
responses_level->items[item]... | ("Tomorrow", root_level) | ,
prv_postpone_tomorrow,
action);
return postpone_level;
}
void timeline_actions_add_action_to_root_level(TimelineItemAction *action,
ActionMenuLevel *root_level) {
const char *label = attribute_get_string... |
cola, ea culpa irure "
"meatball proident laboris ut reprehenderit ex incididunt.\" };\n");
}
}
////////////////////////////////////////////////////////////////////////////////
// .postMessage() Tests
////////////////////////////////////////////////////////////////////////////////
#define SIMPLE_TEST_OBJECT... | (sizeof(raw_bytes_v1), expected_size) | |
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 "crashed_ui.h"
#include "services/common/light.h"
#include "applib/ui/dialogs/dialog.h"
#... | (sizeof(WorkerCrashDialogData)) | ;
data->app_install_id = app_install_id;
// Initialize icons for the worker crash dialog's action bar
GBitmap *check_icon = &data->check_icon;
gbitmap_init_with_resource(check_icon, RESOURCE_ID_ACTION_BAR_ICON_CHECK);
GBitmap *x_icon = &data->x_icon;
gbitmap_init_with_resource(x_icon, RESOURCE_ID_ACTION_BA... |
f (bt_driver_supports_bt_classic()) {
shared_prf_storage_erase_bt_classic_pairing_data();
}
}
static void prv_dump_bonding_db_data(char display_buf[DISPLAY_BUF_LEN],
BTBondingID bond_id, BtPersistBondingData *data) {
bool matches_prf;
if (data->type == BtPersistBondingTy... | {
PBL_ASSERTN(info->val_len == sizeof(bool));
bool is_unfaithful;
memcpy(&is_unfaithful, val, sizeof(bool));
prompt_send_response_fmt(display_buf, DISPLAY_BUF_LEN, "%s : %d",
IS_UNFAITHFUL_KEY, (int)is_unfaithful);
} | else if (memcmp(key, ROOT_KEYS_KEY, info->key_len) == 0) {
SM128BitKey root_keys[SMRootKeyTypeNum], sprf_root_keys[SMRootKeyTypeNum];
PBL_ASSERTN(info->val_len == sizeof(root_keys));
memcpy(&root_keys, val, sizeof(root_keys));
bluetooth_persistent_storage_debug_dump_root_keys(&root_keys[SMRootKeyTypeE... |
ed.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "persist.h"
#include "kernel/memory_layout.h"
#include "process_management/process_manager.h"
#include "services/normal/persist.h"
#include "services/normal/settings/settings_file.h"
#include "sys... | syscall_assert_userspace_buffer(buffer, buffer_size) | ;
}
const size_t restricted_size = MIN(buffer_size, PERSIST_DATA_MAX_LENGTH);
LOCK_AND_GET_STORE(store);
int result = settings_file_set(store, &key, sizeof(key),
buffer, restricted_size);
return PASSED(result) ? (int)restricted_size : result;
}
// Legacy version to prevent 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... | (PULSE_TRANSPORT_PUSH) | ;
PushPacket *transport = (PushPacket *)frame->information;
transport->protocol = hton16(PULSE_PROTOCOL_LOGGING);
transport->length = hton16(sizeof(PushPacket) + sizeof(s_message_header) +
s_message_length);
unsigned char *app = transport->information;
memcpy(app, s_message_head... |
Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writ... | event_put(&e) | ;
}
}
// -----------------------------------------------------------------------------
bool gap_le_consume_scan_results(uint8_t *buffer, uint16_t *size_in_out) {
// The number of bytes left to read:
uint16_t read_space;
// The space left in the output buffer:
uint16_t write_space = *size_in_out;
bt_lock();... |
(method_func_imp) {
++s_method_func_imp_call_count;
return jerry_create_undefined();
}
void test_rocky_api_util__rocky_add_constructor(void) {
static const RockyGlobalAPI *s_api[] = {
NULL,
};
rocky_global_init(s_api);
JS_VAR prototype = rocky_add_constructor("test", test_func_imp);
cl_assert_equal_... | jerry_get_number_value(result_minutes) | |
r_buffer_get_read_space_remaining(
&s_manager_state.system_task_event_buffer);
return avail_bytes / sizeof(PebbleHRMEvent);
}
#endif
static void prv_handle_accel_data(void * data) {
PBL_ASSERT_RUNNING_FROM_EXPECTED_TASK(PebbleTask_NewTimers);
uint64_t timestamp_ms;
uint32_t num_new_samples = sys_accel_m... | {
quality = HRMQuality_NoSignal;
} |
// Update our state
if (quality >= HRMQuality_Good) {
// Once we receive at least one good reading, we are stable
s_manager_state.sensor_stable = true;
s_manager_state.off_wrist_when_stable = false;
} else {
// We haven't yet received a good reading yet. Wait for a timeout...
RtcTicks elapas... |
u bytes receivable",
local_status_out.bytes_sendable_count,
local_status_out.bytes_receivable_count);
HOST_TRANSPORT_DEBUG_LOG("Remote Status: %u bytes sendable, %u bytes receivable",
remote_status_in.bytes_sendable_count,
... | prv_transact(dev) | ) {};
// Re-enable interrupt handling before processing,
// so that endpoint handlers can cause the loop to get unblocked immediately:
prv_reenable_spi_cs_wakeup_interrupt_handling();
if (DialogTaskList[DialogTask_Ble] == 0) {
// We don't bring up the ble task until we have received an init cmd
... |
} else {
WTF;
}
uint8_t register_value;
bool success = prv_read_register(rail_control_reg, ®ister_value);
if (!success) {
// Failed to read the current register value
return false;
}
if (enable) {
if (*ref_count) {
(*ref_count)++;
return true;
} else {
// Set th... | periph_config_acquire_lock() | ;
// Initialize the GPIOs for the 4V5 & 6V6 rails
gpio_output_init(&BOARD_CONFIG_POWER.rail_4V5_ctrl, GPIO_OType_OD, GPIO_Speed_50MHz);
if (BOARD_CONFIG_POWER.rail_6V6_ctrl.gpio) {
gpio_output_init(&BOARD_CONFIG_POWER.rail_6V6_ctrl, GPIO_OType_OD, GPIO_Speed_50MHz);
}
gpio_output_init(&BOARD_CONFIG_ACCES... |
{ -1336, -80, 24},
{ -1312, -96, -24},
{ -1464, 312, -56},
{ -1248, 480, -112},
{ -1280, 192, 128},
{ -1232, 56, 128},
{ -1112, 120, 72},
{ -1000, 128, 144},
{ -880, 80, 256},
{ -864, 128, 320},
{ -944, 256, 288},
{ -976, 312, 312},
{ -1088, 360, 512},
{ -1120, 6... | { -1160, -80, 40},
{ -1240, -152, 72},
{ -1080, -288, 40},
{ -1448, -72, -8},
{ -1328, 272, -128},
{ -1272, 272, -112},
{ -1336, 304, 48},
{ -1336, 136, 144},
// 102 seconds
{ -1144, 192, 176},
{ -976, 208, 216},
{ -1064, 328, 376},
{ -1112, 624, 24},
{ -1056, 408... |
{ -776, 64, 224},
{ -824, 192, 352},
{ -720, 232, 280},
{ -1032, 344, 328},
{ -1200, 264, 288},
{ -1384, 248, 304},
{ -1520, 384, 296},
{ -1056, 240, 232},
{ -1240, 352, 216},
{ -1552, 240, 224},
{ -1512, 56, 104},
{ -1208, 128, 232},
{ -1040, 40, 264},
{ -992, -... |
/*
* 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(secs_to_wait, 100) | ;
cl_assert_equal_i(fake_gap_le_connect_params_get_last_requested(), ResponseTimeMin);
// another consumer at lower rate should not have any effect
fake_gap_le_connect_params_reset_last_requested();
conn_mgr_set_ble_conn_response_time(
&s_hdl, BtConsumerUnitTests, ResponseTimeMiddle, 30);
state = conn_... |
}__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
void inside_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_draw_pixel(ctx, GPoint(5, 5));
}
void white_layer_update_callback(Layer* me, GContext* ctx) {
graphics_conte... | framebuffer_is_empty("outside_y_offset_layer", ctx.parent_framebuffer, GColorWhite) | |
/*
* 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... | load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME, false /* is_next */) | ;
load_resource_fixture_on_pfs(RESOURCES_FIXTURE_PATH, CHINESE_FIXTURE_NAME, "lang");
//cl_assert(resource_has_valid_system_resources());
memset(&s_font_info, 0, sizeof(s_font_info));
memset(&s_font_cache, 0, sizeof(s_font_cache));
FontCache *font_cache = &s_font_cache;
memset(font_cache->cache_keys, 0, s... |
context_move_draw_box(GContext* ctx, GPoint offset) {}
typedef uint16_t ResourceId;
const uint8_t *resource_get_builtin_bytes(ResAppNum app_num, uint32_t resource_id,
uint32_t *num_bytes_out) { return NULL; }
typedef struct TestReelData {
uint32_t elapsed_ms;
uint32_t dura... | cl_assert_equal_i(animation_is_scheduled(animation), false) | ;
animation_schedule(animation);
animation_set_reverse(animation, true);
animation_set_elapsed(animation, 1234); // intentionally bad value
prv_play_animation_update(animation,
ANIMATION_NORMALIZED_MAX - ANIMATION_NORMALIZED_MAX * 20 / 300);
cl_assert_equal_i(kino_reel_get_elaps... |
/*
* 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... | flash_calculate_legacy_defective_checksum(
start_address, firmware_description->firmware_length) | ;
#else
const uint32_t calculated_crc = flash_crc32(start_address, firmware_description->firmware_length);
#endif
PBL_LOG(LOG_LEVEL_DEBUG, "CRCing recovery... done");
return calculated_crc == firmware_description->checksum;
}
|
/*
* 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_consume(buffer, client, chunk) | );
buffer += chunk;
num_bytes -= chunk;
}
}
void test_shared_circular_buffer__one_client(void) {
SharedCircularBuffer buffer;
uint8_t storage[9];
shared_circular_buffer_init(&buffer, storage, sizeof(storage));
const uint8_t* out_buffer;
uint16_t out_length;
// Add a client
SharedCircularBuff... |
onInfo *enc_info) {
key_ltk_t *ltk = kernel_zalloc_check(sizeof(key_ltk_t));
ltk->rand = enc_info->rand;
ltk->ediv = enc_info->ediv;
memcpy(ltk->key, enc_info->ltk.data, sizeof(ltk->key));
ltk->key_size = sizeof(ltk->key);
return ltk;
}
void bonding_sync_handle_hc_add(const BleBonding *bonding) {
storage... | (LOG_LEVEL_ALWAYS, "Device did not exchange an IRK") | ;
info->is_remote_identity_info_valid = true;
dialog_utils_bd_address_to_bt_device(&dev->addr, &info->identity);
}
info->is_mitm_protection_enabled = dev->mitm;
bonding.is_gateway = connection_is_gateway(connection);
if (connection_should_pin_address(connection)) {
bonding.should_pin_... |
urve curve) {
if (dy == 0) {
return;
}
ScrollAnimationCurve moook_scroll_curve = (ScrollAnimationCurve) {
.swap_curve_kind = ScrollAnimationCurveKind_Interpolator,
.interpolator = interpolate_moook
};
Animation *current = prv_create_anim_frame_scroll((Layer *)swap_layer->current, SCROLL_MS, dy... | (swap_layer) | ;
#if PBL_ROUND
is_repeating = false;
#endif
int16_t offset = prv_get_current_notification_offset(swap_layer);
int16_t max_dy = prv_get_max_scroll_dy(swap_layer);
// distance to scroll
int16_t dy = 0;
// check if we are going to go off screen, if so get a new layer and set it up, then animate.
switch ... |
/*
* 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... | (round(-0.4), -0.0) | |
nder_timeline_peek(&(TimelinePeekItemConfig) {
.timestamp = rtc_get_time() + (5 * SECONDS_PER_MINUTE),
.title = "Stock for party 🍺",
.subtitle = "Pebble Pad on Park",
.icon = TIMELINE_RESOURCE_NOTIFICATION_REMINDER,
.num_concurrent = 2,
});
cl_check(gbitmap_pbi_eq(s_dest_bitmap, TEST_PBI_FILE))... | timeline_item_destroy(item) | ;
}
void test_timeline_peek__peek_visible_leaving_and_entering_watchface(void) {
TimelineItem *item = prv_set_timeline_item(&(TimelinePeekItemConfig) {
.title = "CoreUX Design x Eng",
.subtitle = "ConfRM-Missile Command",
.icon = TIMELINE_RESOURCE_TIMELINE_CALENDAR,
.num_concurrent = 0,
}, 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... | (FLASH_GPIO, FLASH_PIN_SCS) | ;
// 50ns required between SCS going high and low again, so just delay here to be safe
delay_us(1);
}
static uint8_t prv_flash_send_and_receive_byte(uint8_t byte) {
// Ensure that there are no other write operations in progress
while (SPI_I2S_GetFlagStatus(FLASH_SPI, SPI_I2S_FLAG_TXE) == RESET) {
continue... |
nimation_state();
return list_count(state->unscheduled_head) + list_count(state->scheduled_head);
}
// --------------------------------------------------------------------------------------
// Count how many animations have been scheduled
static uint32_t prv_count_scheduled_animations(void) {
AnimationState *state... | (&layer, &from_r, &to_r) | ;
Animation *h = property_animation_get_animation(prop_h);
void *context = &layer;
animation_set_handlers(h, handlers, context);
animation_set_duration(h, duration);
animation_set_auto_destroy(h, false);
// Clone it and make sure the clone is correct
PropertyAnimation *clone_h = (PropertyAnimation *)ani... |
include "util.h"
#include <string.h>
#include <stdio.h>
// Stubs
////////////////////////////////////
#include "graphics_common_stubs.h"
#include "stubs_applib_resource.h"
#include "test_graphics.h"
extern void prv_apply_tint_color(GColor *color, GColor tint_color);
static uint8_t s_dest_data[100 * 100];
static GBi... | bitblt_bitmap_into_bitmap(&s_dest_bitmap, src_bitmap, GPointZero, GCompOpSet, GColorWhite) | ;
cl_assert(gbitmap_pbi_eq(&s_dest_bitmap,
"test_bitblt_palette_1bit__2bit_palette_to_1bit_set-expect.pbi"));
gbitmap_destroy(src_bitmap);
}
// Tests assign, from same size to same size.
// Setup:
// - Source is 50x50, alternating lines between orange and blue for the top half.
// The bott... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return EX_GPOINT;
} |
void test_clar__equal_gpoint(void) {
// test with local variable
GPoint a = EX_GPOINT;
GPoint b = EX_GPOINT;
cl_assert_equal_gpoint(a, b);
// test with reference
cl_assert_equal_gpoint(prv_get_gpoint(), prv_get_gpoint());
}
// GSize
/////////////////////////
#define EX_GSIZE GSize(5, 6)
static GSize p... |
) {
ListNode *next = list_get_next((ListNode *)tmp);
kernel_free(tmp);
tmp = next;
}
if (connection->ppogatt_wa_state) {
ppogatt_destroy_state(connection->ppogatt_wa_state);
}
kernel_free(connection);
}
}
prv_unlock();
}
bool connection_is_valid(Connect... | prv_lock() | |
* limitations under the License.
*/
#include "comm/ble/kernel_le_client/ancs/ancs.h"
#include "comm/ble/kernel_le_client/ancs/ancs_util.h"
#include "comm/ble/kernel_le_client/ancs/ancs_definition.h"
#include "comm/ble/gap_le_connection.h"
#include "comm/ble/gap_le_task.h"
#include "services/common/evented_timer.h"
... | (ancs_notification_dict, 0) | ;
}
static uint8_t *prv_serialize_timeline_item(TimelineItem *item, size_t *size_out) {
size_t payload_size = timeline_item_get_serialized_payload_size(item);
*size_out = sizeof(SerializedTimelineItemHeader) + payload_size;
uint8_t *buffer = malloc(*size_out);
timeline_item_serialize_header(item, (SerializedT... |
current_hour = 10;
s_current_minute = 30;
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 1);
}
void test_alarm__recurring_daily_alarm_timeout_behind(void) {
AlarmId id;
s_current_hour = 11;
s_current_minute = 30;
id = alarm_create(&(AlarmInfo) { .hour = 10, .minute = 30, .kind = ALARM_KIND_... | (s_last_timeline_item_added->header.timestamp, rtc_get_time()) | ;
// First alarm goes off. Second one should be up
s_current_hour = 10;
s_current_minute = 30;
s_current_day = s_sunday; // Make sure the wday can wrap properly
cron_service_wakeup();
cl_assert_equal_i(s_num_alarms_fired, 7);
cl_assert_equal_i(s_num_alarm_events_put, 7);
cl_assert_equal_i(s_num_timelin... |
me files
int fd;
fd = pfs_open("a_test_0", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
fd = pfs_open("a_test_1", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
fd = pfs_open("b_test_0", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
fd = pfs_open("b_test_1", OP_FLAG_W... | {
pfs_format(true);
pfs_init(false);
// Create some files
int fd;
fd = pfs_open("a_test_0", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
pfs_close(fd);
fd = pfs_open("a_test_1", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
pfs_close(fd);
fd = pfs_open("b_test_0", OP_FLAG... |
void test_pfs__doesnt_give_out_fd_zero(void) {
for (int i = 5; i > 0; --i) {
char filename[20];
sprintf(filename, "test%d", i);
int fd = pfs_open(filename, OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd > 0);
}
}
|
-------------------
// We start time out at 5pm on Jan 1, 2015 for all of these tests
static const struct tm s_init_time_tm = {
// Thursday, Jan 1, 2015, 5:pm
.tm_hour = 17,
.tm_mday = 1,
.tm_mon = 0,
.tm_year = 115
};
// Logged items
#define TEST_PL_DLS_SESSION_ID 1
typedef struct {
uint8_t data[PLOG_DLS... | (&s_types, 0, sizeof(s_types)) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | window_set_on_screen(&window, true, true) | ;
window_render(&window, &s_ctx);
}
// Tests
//////////////////////
void test_health_hr_summary_card__render_no_data(void) {
prv_create_card_and_render(&(HealthData) {});
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_hr_summary_card__render_current_bpm(void) {
HealthData hea... |
e_s, GColor secondary_color, bool is_ingame,
bool has_broadcaster) {
const time_t now = rtc_get_time();
AttributeList list = {};
prv_set_timeline_icon(&list, TIMELINE_RESOURCE_TIMELINE_SPORTS, 0);
attribute_list_add_uint8(&list, AttributeIdSecondaryColor, secondary_color.argb);
... | attribute_list_add_cstring(&list, AttributeIdSubtitle, "Open Table Reservation") | |
/*
* 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... | {
// We're done here. Return the app's main function.
event_cleanup(&event);
return;
} | |
/*
* 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... | kino_reel_get_type(kino_reel) | == KinoReelTypePDCI);
cl_assert_equal_i(kino_reel_get_data_size(kino_reel), 192);
}
void test_kino_reel__resource_pdcs(void) {
// Test loading PDCS Kino Reel
uint32_t resource_id = sys_resource_load_file_as_resource(
TEST_IMAGES_PATH, "test_kino_reel__resource_pdcs.pdc");
cl_assert(resource_id != UINT32... |
torage, key, key_len,
val, val_len, mark_synced);
if (rv == S_SUCCESS) {
TimelineItemId parent_id = ((CommonTimelineItemHeader *)val)->parent_id;
if (timeline_get_private_data_source(&parent_id)) {
goto done;
}
// Not a private data source, must be a... | (pin, header, payload) | ) {
status = E_INTERNAL;
goto cleanup;
}
task_free(read_buf);
return (S_SUCCESS);
cleanup:
task_free(read_buf);
return status;
}
bool pin_db_exists_with_parent(const TimelineItemId *parent_id) {
return timeline_item_storage_exists_with_parent(&s_pin_db_storage, parent_id);
}
status_t pin_db_read... |
ce_level,
"This won't be seen",
prv_noop_action_callback,
NULL);
action_menu_level_add_child(root_level, voice_level, "Voice");
ActionMenuLevel *template_level = action_menu_level_create(1);
action_menu_level_add_action(... | action_menu_level_add_action(root_level,
"Change Time",
prv_noop_action_callback,
NULL) | ;
action_menu_level_add_action(root_level,
"Change Days",
prv_noop_action_callback,
NULL);
ActionMenuLevel *snooze_level = action_menu_level_create(1);
action_menu_level_add_action(snooze_level,
... |
switch (event->object_type) {
case ObjectFirmware:
status->firmware_percent_completion = event->progress_percent;
break;
case ObjectSysResources:
status->resource_percent_completion = event->progress_percent;
break;
case ObjectRecovery:
status->recovery_percent_completion =... | {
return progress;
} |
FwUpdateCompletionStatus *status = &s_current_completion_status.status;
return (status->bytes_transferred * 100) / status->total_size;
}
void firmware_update_event_handler(PebbleSystemMessageEvent* event) {
switch (event->type) {
case PebbleSystemMessageFirmwareUpdateStartLegacy:
case PebbleSystemMessa... |
if (!memory_layout_is_pointer_in_region(memory_layout_get_readonly_bss_region(), fontinfo)) {
syscall_failed();
} |
}
text_resources_init_font(fontinfo->base.app_num, fontinfo->base.resource_id,
fontinfo->extension.resource_id, fontinfo);
}
| |
", data->operation);
break;
}
layer_mark_dirty(data->canvas_layer);
PBL_LOG(LOG_LEVEL_DEBUG, "line(p1(%d, %d), p2(%d, %d), width=%d), angle=%d)",
data->p1.x, data->p1.y, data->p2.x, data->p2.y, data->stroke_width,
(int)(data->rotation_angle * 360 / TRIG_MAX_ANGLE));
}
static void sele... | (ctx, GPoint(70, 100), GPoint(70, 101)) | ;
return;
}
if (data->operation == OP_ROTATE2) {
int line_length = 60;
time_t now;
uint16_t now_ms = time_ms(&now, NULL);
uint32_t seconds = pbl_override_localtime(&now)->tm_sec;
uint32_t miliseconds = seconds * 1000 + now_ms;
uint32_t rotation = miliseconds * TRIG_MAX_ANGLE / (60 * 1... |
, int x, int y);
#endif
// @param color_index the color index (the value) to put into the bitmap at (x, y).
// @param bpp Bits per pixel.
// @para line_stride how many bytes per line in the bitmap data.
void packed_pixel_set(uint8_t *buf, uint8_t color_index, int16_t x, int16_t y,
uint8_t bpp, in... | (dest_bitmap_data, GColorWhite.argb, sizeof(dest_bitmap_data)) | ;
#if SCREEN_COLOR_DEPTH_BITS == 8
char print_buf[20];
for (int y = 0; y < HEIGHT; ++y) {
for (int x = 0; x < WIDTH; ++x) {
snprintf(print_buf, sizeof(print_buf), "Failed index = %d, %d", x, y);
cl_check_(gcolor_equal(get_bitmap_color(&s_bmp, x, y), s_palette[x]), print_buf);
cl_check_(gcolor... |
_write_key(&new_file.iter, key);
settings_raw_iter_write_val(&new_file.iter, val);
settings_raw_iter_next(&new_file.iter);
}
kernel_free(key);
kernel_free(val);
}
settings_file_close(file);
// We have to close and reopen the new_file so that it's temp flag is cleared.
// Before the close... | {
return cleanup_partial_transactions(file);
} |
int settings_file_get_len(SettingsFile *file, const void *key, size_t key_len) {
settings_raw_iter_resume(&file->iter);
if (search_forward(&file->iter, key, key_len)) {
return file->iter.hdr.val_len;
} else {
return 0;
}
}
bool settings_file_exists(SettingsFile *file, const void *key, size_t key_len)... |
/*
* 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... | ABS(center.y - range_start) | ;
const int32_t start_width = prv_triangle_side(radius, height);
// height of triangle from center to range end
height = ABS(center.y - range_end);
const int32_t end_width = prv_triangle_side(radius, height);
width = MIN(start_width, end_width);
return (GRangeHorizontal){.origin_x = center.x - width, .si... |
lse;
const bool animated = true;
menu_layer_set_selected_next(menu_layer, up, MenuRowAlignCenter, animated);
}
static void prv_menu_click_config_provider(MenuLayer *menu_layer) {
// The config that gets passed in, has already the UP and DOWN buttons configured
// we're overriding the default behavior here:
w... | (0, y, menu_layer->scroll_layer.layer.bounds.size.w, cursor->sep) | );
}
}
static void prv_prepare_row(GContext *ctx, MenuLayer *menu_layer,
Layer *cell_layer, bool highlight) {
if (!process_manager_compiled_with_legacy2_sdk()) {
GColor *colors = (highlight) ? menu_layer->highlight_colors : menu_layer->normal_colors;
ctx->draw_state.fill_color =... |
core_dump_private.h"
#include "mfg/mfg_mode/mfg_factory_mode.h"
#include "resource/resource_storage_flash.h"
#include "services/common/new_timer/new_timer.h"
#include "services/common/system_task.h"
#include "services/prf/accessory/accessory_manager.h"
#include "system/bootbits.h"
#include "system/logging.h"
#include "... | (AccessoryInputStateMfg) | ;
new_timer_delete(s_timeout_timer);
PBL_LOG(LOG_LEVEL_DEBUG, "Stopping accessory imaging");
}
static void prv_timeout_timer_cb(void *context) {
system_task_add_callback(prv_stop, NULL);
}
// Sending
////////////////////////////////////////////////////////////////////
static void prv_encode_and_send_data(cons... |
ULT);
// 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_offset_r4_aa_sw11_clip_xy.${BIT_DEPTH_NAME}.pbi"));
#endif
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, true, 11);
graphic... | (gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi")) | ;
#endif
// SW = 5
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 5);
graphics_draw_round_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP, RADIUS_DEFAULT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_offset_r4_sw5_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | while ((uint8_t *)arg < (uint8_t *)msg + msg->header.length) {
if (((msg->body.msgid.str_index_1 != 0) && (arg_index + 1 == (msg->body.msgid.str_index_1))) ||
((msg->body.msgid.str_index_2 != 0) && (arg_index + 1 == (msg->body.msgid.str_index_2)))) {
// String. TODO: the string is null terminated for ... |
// Fixup the hash (add the #args, ignore the task id for now, leave the level 0) TODO.
uint32_t hash = ((msg->body.msgid.msg_id & MSGID_STR_AND_HASH_MASK) |
((arg_index & PACKED_NUM_FMT_MASK) << PACKED_NUM_FMT_OFFSET));
// The core must be in the correct position for pbl_log_hashed_core.
ui... |
/*
* 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_low_power_data->low_power_time_layer,
s_low_power_data->time_text+1) | ;
} else {
text_layer_set_text(&s_low_power_data->low_power_time_layer,
s_low_power_data->time_text);
}
}
static void deinit(void) {
tick_timer_service_unsubscribe();
kino_layer_deinit(&s_low_power_data->low_power_kino_layer);
app_free(s_low_power_data);
}
static void init(vo... |
it(DisplayContext* context);
static void prv_setup_dma_transfer(uint8_t* framebuffer_addr, int framebuffer_size);
static bool prv_do_dma_update(void);
static void prv_enable_display_spi_clock() {
periph_config_enable(BOARD_CONFIG_DISPLAY.spi, BOARD_CONFIG_DISPLAY.spi_clk);
power_tracking_start(PowerSystemMcuSpi2)... | prv_display_write_byte(DISP_MODE_CLEAR) | ;
prv_display_write_byte(0x00);
prv_disable_chip_select();
prv_disable_display_spi_clock();
}
bool display_update_in_progress(void) {
if (xSemaphoreTake(s_dma_update_in_progress_semaphore, 0) == pdPASS) {
xSemaphoreGive(s_dma_update_in_progress_semaphore);
return false;
}
return true;
}
void disp... |
wSamplesRecord *record = &s_dls_accel_records[i];
// Verify the header info
cl_assert_equal_i(record->version, ACTIVITY_RAW_SAMPLES_VERSION);
cl_assert_equal_i(record->len, sizeof(ActivityRawSamplesRecord));
if (i == 0) {
cl_assert(record->flags & ACTIVITY_RAW_SAMPLE_FLAG_FIRST_RECORD);
} els... | {
time_t now = rtc_get_time();
s_health_sessions_count = 0;
s_health_sessions_max = *session_entries;
s_health_sessions = sessions;
s_health_sessions_awake_time = 0;
s_health_sessions_sleep_time = 0;
health_service_activities_iterate(HealthActivityMaskAll, now - (2 * SECONDS_PER_DAY), now,
... | |
dev->periph->BRR = (mantissa << 3) | (fraction & 0x7);
} else {
// 4 bits of fraction
dev->periph->BRR = (mantissa << 4) | (fraction & 0xF);
}
}
// Read / Write APIs
////////////////////////////////////////////////////////////////////////////////
void uart_write_byte(UARTDevice *dev, uint8_t data) {
... | (dev, data, &err_flags) | ) {
should_context_switch = true;
}
if (++dev->state->rx_dma_index == dma_length) {
dev->state->rx_dma_index = 0;
}
}
// explicitly clear error flags since we're not reading from the data register
uart_clear_all_interrupt_flags(dev);
} else {
const... |
mp(token, "TEST_IN_DEEP_SLEEP_MAX") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.in_deep_sleep.max);
} else if (strcmp(token, "TEST_FORCE_SHUT_DOWN_AT") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.force_shut_down_at);
} else if (strcmp(token, "T... | strcmp(token, "TEST_ACTIVITY_TYPE_MAX") | == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.activity_type.max);
} else if (strcmp(token, "TEST_LEN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.len.value);
} else if (strcmp(token, "TEST_LEN_MIN") == 0) {
sscanf(token + strlen(token) +... |
ance_meters = ROUND(distance_mm, MM_PER_METER),
},
};
if (delete) {
activity_sessions_prv_delete_activity_session(&session);
} else {
activity_sessions_prv_add_activity_session(&session);
}
}
// ------------------------------------------------------------------------------------------
// Used from... | {
if (!prv_lock()) {
return false;
}
bool success = false;
SettingsFile *file = NULL;
// Open the minute data file
file = prv_minute_data_file_open();
if (!file) {
goto exit;
}
// Figure out the oldest and newest possible time stamp for chunks that go into these buffers
time_t now = rtc_g... | |
.h"
#include "stubs_sleep.h"
#include "stubs_system_reset.h"
#include "stubs_task_watchdog.h"
static PebbleProcessMd __pbl_app_info;
const PebbleProcessMd* sys_process_manager_get_current_process_md(void) {
return &__pbl_app_info;
}
// Tests
////////////////////////////////////
#define TEST_UUID_A { 0x2F, 0xF7, 0x... | persist_write_bool(key, true) | , sizeof(bool));
cl_assert_equal_i(persist_get_size(key), sizeof(bool));
cl_assert_equal_i(persist_read_bool(key), true);
}
void test_persist__data(void) {
const uint32_t key = 0;
const int size = sizeof(test_uuid_a);
Uuid uuid_buffer;
cl_assert_equal_i(persist_read_data(key, &uuid_buffer, sizeof(uuid_buff... |
lude "util/size.h"
#include "workout_active.h"
#include "workout_controller.h"
#include "workout_metrics.h"
#include <limits.h>
#include <stdio.h>
enum {
SPORTS_TIME_KEY = 0x0, // TUPLE_CSTRING
SPORTS_DISTANCE_KEY = 0x1, // TUPLE_CSTRING
SPORTS_DATA_KEY = 0x2, // TUPLE_CSTRING
SPOR... | health_service_set_heart_rate_sample_period(0 /* interval_s */) | ;
prv_update_scrollable_metrics(data);
}
data->current_bpm = new_tuple->value->uint8;
break;
}
case SPORTS_CUSTOM_LABEL_KEY:
{
if (strncmp(new_tuple->value->cstring,
data->custom_label_string,
sizeof(data->custom_label_string)) != 0) {
... |
line vertically aligned.
// So we also have to subtract half of a single line's width.
box.origin.y = (box.size.h - text_size.h - fonts_get_font_height(font)/2) / 2;
graphics_draw_text(ctx, no_activities_string, font, box, overflow, alignment, NULL);
}
static void prv_draw_no_activities_cell_round(GContext *ctx... | (&data->option_menu, &option_menu_callbacks, data) | ;
prv_reload_menu_data(data);
data->worker_launch_info = (EventServiceInfo) {
.type = PEBBLE_WORKER_LAUNCH_EVENT,
.handler = prv_worker_launch_handler,
.context = data
};
event_service_client_subscribe(&data->worker_launch_info);
return &data->option_menu.window;
}
const SettingsModuleMetadata ... |
complete_loc_init__rcv_chunk(void) {
prv_init_and_goto_awaiting_reset_complete_local_initiated();
RCV_DUMMY_CHUNK();
// https://pebbletechnology.atlassian.net/browse/PBL-42466
// TODO: assert that chunk is NACK'd
// Chunk is ignored, state isn't changed:
cl_assert_equal_i(rocky_api_app_message_get_state(... | ASSERT_JS_GLOBAL_EQUALS_I("c", 1) | ;
ASSERT_JS_GLOBAL_EQUALS_I("d", 1);
// Get a ResetComplete (unexpected message), should trigger initiating (local) ResetRequest:
RCV_RESET_COMPLETE();
ASSERT_JS_GLOBAL_EQUALS_I("d", 2);
}
void test_rocky_api_app_message__postmessageconnected_and_postmessagedisconnected_start_conn(void) {
prv_postmessagecon... |
(fake_comm_session_send_buffer_write_raw_by_transport(transport,
s_short_data_fragment,
sizeof(s_short_data_fragment) - sn), true) | ;
ppogatt_send_next(transport);
prv_assert_sent_data(s_characteristics[0][PPoGATTCharacteristicData], sn,
s_short_data_fragment, sizeof(s_short_data_fragment) - sn);
if (sn == 0 || sn == 1) {
// Make the first and second packet time out each, one second earlier
// than t... | |
pt in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIN... | {
*is_resolved_out = is_resolved;
} | |
mponent(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 500;
const int play_count_seq = 2;
int duration_total = play_count_seq * duration_a;
// Create 2 animations
Animation *a = prv_create_test_animation();
animation_set_duration(a, duration_a);
Animation *b = p... | (start_ms + 1) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 0)... |
cl_assert_equal_i(s_data.num_did_change_calls, 1);
}
void test_unobstructed_area_service__did_change_after_subscribe(void) {
const GRect from_area = GRect(0, 0, DISP_COLS, 400);
const GRect to_area = GRect(0, 0, DISP_COLS, 200);
unobstructed_area_service_will_change(from_area.size.h, to_area.size.h);
Unobs... | layer_get_unobstructed_bounds(&layer, &unobstructed_bounds) | ;
cl_assert_equal_grect(unobstructed_bounds, GRect(150, 120, 40, 40));
}
|
/*
* 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... | (atoi("21474836481"), 1) | ;
// ((2147483647 * 10) + 1) & 0xFFFFFFFF
cl_assert_equal_i(atoi("21474836471"), (int)4294967287);
// -1 * (((2147483647 * 10) + 1) & 0xFFFFFFFF)
cl_assert_equal_i(atoi("-21474836471"), -(int)4294967287);
}
// atol will actually behave _exactly_ the same as atoi, so these tests are just copy-pasted
// Would pr... |
FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
fd = pfs_open("b_test_0", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
fd = pfs_open("b_test_1", OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_assert(fd >= 0);
// Get a directory listing with no filtering
PFSFileListEntry *dir_list;
dir_lis... | (prv_file_exists("b_test_0"), true) | ;
cl_assert_equal_b(prv_file_exists("b_test_1"), true);
pfs_remove_files(prv_filename_filter_a_prefix_cb);
// Should have only files starting with b_
cl_assert_equal_b(prv_file_exists("a_test_0"), false);
cl_assert_equal_b(prv_file_exists("a_test_1"), false);
cl_assert_equal_b(prv_file_exists("b_test_0"),... |
ET_RECT_CLIP_NXNY, true, 5);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_aa_sw5_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
// TODO: Fix offset calculation and reenable this: - PBL-16509
#if SCREEN_COLOR_DEPTH_BITS == 8
// AA = true, SW = 11
set... | (&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_offset_sw4_clip_nxny.${BIT_DEPTH_NAME}.pbi"));
#endif
// SW = 5
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_NO_CLIP, OFFSET_RECT_NO_CLIP, false, 5);
graphics_draw_rect(&ctx, &OFFSET_DRAW_RECT_NO_CLIP);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_off... |
/*
* 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... | for (int j = 0; j < 4; j++) {
rv = ecomp_corr_add_raw_mag_sample(s_sample_data[i].raw_samples[j],
NULL, solution);
if (j != 3) {
// add the same sample twice to make sure close values are thrown away
rv = ecomp_corr_add_raw_mag_sample(s_sample_data[i].raw_samples[j],
NU... |
cl_assert_equal_i(rv, ((num_entries - 1) == i) ?
MagCalStatusNewLockedSolutionAvail : MagCalStatusNewSolutionAvail);
if (rv == MagCalStatusNewSolutionAvail) {
solution_and_estimate_match(solution, s_sample_data[i].sphere_fit_corr);
// should be avg of last 3 solutions
} else if (rv == Ma... |
(GRect(0, 0, -20, 10)) | );
}
void test_gtypes__grect_inset(void) {
GRect rect = GRect(10, 20, 30, 40);
cl_assert_equal_grect(GRect(12, 23, 26, 34), grect_inset_internal(rect, 2, 3));
cl_assert_equal_grect(GRect(7, 18, 36, 44), grect_inset_internal(rect, -3, -2));
}
void test_gtypes__grect_inset_standardizes(void) {
GRect rect = GRe... | |
vices/normal/timeline/timeline_actions.h"
#include "services/normal/timeline/timeline_resources.h"
#include "system/logging.h"
#include "system/passert.h"
#include "util/math.h"
#include "util/trig.h"
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#if CAPABILITY_HAS_VIBE_SCORES
#include "services/normal... | {
return;
} | |
ance_2);
cl_assert_equal_i(app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&app_glance_2, glance_2_size),
E_INVALID_ARGUMENT);
}
void test_app_glance_db__glance_blob_with_too_many_slices_inserted_but_trimmed(void) {
const siz... | app_glance_db_insert_stale((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&app_glance, sizeof(app_glance)) | ,
S_SUCCESS);
// Verify that trying to read the blob back fails due to it not existing
SerializedAppGlanceHeader glance_out = {};
cl_assert_equal_i(app_glance_db_read((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&glance_out, sizeof(SerializedA... |
EXPECT_OUTBOX_MESSAGE_PENDING(TupletBytes(PostMessageKeyChunk,
(const uint8_t *) chunk, expected_size));
// Compare with hard-coded byte array, to catch accidental changes to the ABI:
const uint8_t raw_bytes_v1[] = {
0x08, 0x00, 0x00, 0x00, '}', '\0',
... | EXECUTE_SCRIPT("var didError = false;"
"var x = { \"x\" : 1 };"
"var dataJSON = undefined;"
"_rocky.on('postmessageerror', "
" function(e) { didError = true; dataJSON = JSON.stringify(e.data); });"
"_rocky.postMessage(x);"
... | ;
ASSERT_JS_GLOBAL_EQUALS_B("didError", false);
for (int i = 0; i < 3; ++i) {
cl_assert_equal_b(s_is_outbox_message_pending, true);
// NACK
prv_rcv_app_message_ack(APP_MSG_BUSY);
AppTimer *t = rocky_api_app_message_get_app_msg_retry_timer();
cl_assert(t != EVENTED_TIMER_INVALID_ID);
cl_a... |
nstall_entry);
static AppInstallId s_pending_app_deletion;
static AppInstallId s_pending_worker_deletion;
// PBL-31769: This should be moved to send_text.c
#if !PLATFORM_TINTIN && defined(APP_ID_SEND_TEXT)
static EventServiceInfo s_capabilities_event_info;
#endif
//////////////////
// Misc helpers
//////////////////... | {
case ProcessVisibilityHidden:
return true;
case ProcessVisibilityShownOnCommunication:
// make icon hidden (return true) if app has not recently communicated
return !app_install_is_prioritized(entry->install_id);
case ProcessVisibilityShown:
return false;
case ProcessVisibility... |
return false;
}
bool app_install_entry_is_quick_launch_visible_only(const AppInstallEntry *entry) {
return (entry->visibility == ProcessVisibilityQuickLaunch);
}
bool app_install_entry_is_SDK_compatible(const AppInstallEntry *entry) {
return (entry->sdk_version.major == PROCESS_INFO_CURRENT_SDK_VERSION_MAJOR &... |
0, -144},
{ 1080, 384, -232},
{ 1056, 416, -264},
{ 1064, 368, -200},
{ 1296, 360, -184},
{ 1144, 368, -208},
// 140 seconds
{ 984, 320, -168},
{ 1048, 304, -112},
{ 1192, 312, -48},
{ 1200, 272, 32},
{ 1040, 200, 32},
{ 824, 168, -16},
{ 744, 176, -32},
{ 784, 18... | {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_200_pbl_25656_9
//> TEST_EXPECTED 200
//> TEST_EXPECTED_MIN 165
//> TEST_EXPECTED_MAX 230
//> TEST_WEIGHT 1.0
static AccelRawData samples[] = {
// 0 seconds
// elapsed: 0 minutes
{ -488, 544, 600},
{ -... |
{ 192, 32, -864},
{ 120, 104, -928},
{ 192, 0, -904},
{ 224, 184, -976},
{ 312, 88, -944},
{ 304, 208, -992},
{ 368, 176, -960},
{ 408, 248, -960},
{ 440, 216, -920},
{ 504, 240, -904},
{ 528, 224, -832},
{ 544, 208, -800},
{ 576, 208, -744},
{ 608, 248, -720},
... |
age governing permissions and
* limitations under the License.
*/
#include "progress_ui_app.h"
#include "applib/app.h"
#include "applib/app_timer.h"
#include "applib/graphics/gpath_builder.h"
#include "applib/graphics/graphics.h"
#include "util/trig.h"
#include "applib/ui/dialogs/dialog.h"
#include "applib/ui/dialo... | {
if (firmware_update_current_status() == FirmwareUpdateFailed) {
prv_handle_finished(data, false /* success */);
return;
} else if (firmware_update_current_status() == FirmwareUpdateStopped) {
prv_handle_finished(data, true /* success */);
return;
}
data->percen... |
}
prv_update_progress_text(data);
progress_layer_set_progress(&data->progress_layer,
PROG_LAYER_TRANSFORM(data->percent_complete));
if ((data->progress_source != PROGRESS_UI_SOURCE_FW_UPDATE) &&
(data->percent_complete >= 100)) {
prv_handle_finished(data, true /* suc... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (0, origin_y, time_selection_window->window.layer.bounds.size.w,
(lines + 1) * line_height + line_height / 2) | ; // 1/2 more for descenders
layer_set_frame(&text_layer->layer, &frame);
#if PBL_ROUND
const int inset = 4;
text_layer_enable_screen_text_flow_and_paging(text_layer, inset);
#endif
const GSize content_size = app_text_layer_get_content_size(text_layer);
if (content_size.h > lines * line_height) {
frame = ... |
x=<%u>",
cursor.origin.x, line->origin.x);
const int glyph_width_px = prv_codepoint_get_horizontal_advance(&ctx->font_cache,
text_box_params->font, codepoint);
line->width_px = (cursor.origin.x + glyph_width_px) - line->origin.x;
PBL_ASSERT(line->width_px <= text_box_params->box.size.w,
"Line... | {
break;
} | |
MENU_LAYER_APP_ID, APP_ID_MUSIC};
AppInstallId desired_order[] = {APP_ID_MUSIC, APP_ID_SETTINGS, APP_ID_NOTIFICATIONS,
APP_ID_ALARMS, APP_ID_WATCHFACES, APP_ID_WORKOUT,
BG_COUNTER_APP_ID, MENU_LAYER_APP_ID};
uint8_t num_entries = ARRAY_LENGTH(wr... | for (uint16_t i = 0; i < num_apps; i++) {
AppMenuNode *node = app_menu_data_source_get_node_at_index(&data_source, i);
cl_assert_equal_i(node->install_id, desired_order[i]);
} | |
e
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_assert(iter_next(... | cl_assert(*word_iter_state.current.end == 'a') | ;
cl_assert(word_iter_state.current.width_px == HORIZ_ADVANCE_PX * 0);
line_reset(&line, utf8_bounds.start);
cl_assert(line_add_words(&line, &word_iter, NULL));
cl_assert(line.height_px == 10);
cl_assert(line.width_px == HORIZ_ADVANCE_PX * 0);
cl_assert(line.origin.x == 0);
cl_assert(line.suffix_codepoin... |
/*
* 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... | strnlen(attr_text, ATTRIBUTE_TITLE_MAX_LEN) | ;
if (pos + 1 /* one space */ < config->buffer_size) {
buffer[pos++] = ' ';
char time_buffer[TIME_STRING_REQUIRED_LENGTH];
clock_copy_time_string_timestamp(time_buffer, sizeof(time_buffer), layout->info->timestamp);
strncpy(buffer + pos, time_buffer, config->buffer_size - pos);
buffer[config->buff... |
atic Window s_app_window_stack_get_top_window;
Window *app_window_stack_get_top_window() {
return &s_app_window_stack_get_top_window;
}
// no text rendering in this test
void rocky_api_graphics_text_init(void) {}
void rocky_api_graphics_text_deinit(void) {}
void rocky_api_graphics_text_add_canvas_methods(jerry_value... | prv_global_init_and_set_ctx() | ;
// taken from http://fiddle.jshell.net/a5gjzb7c/6/
EXECUTE_SCRIPT(
"function render(x, y, f) {\n"
" f(x + 10, y + 10, 10, 10);\n"
" f(x + 30.2, y + 10, 10, 10.2);\n"
" f(x + 50.5, y + 10, 10, 10);\n"
" f(x + 70.7, y + 10, 10.5, 10.8);\n"
" f(x + 10, y + 30.5, 10, 10);\n... |
m_pairing_info.is_remote_identity_info_valid = true;
shared_prf_storage_store_ble_pairing_data(&sm_pairing_info, PAIRING_NAME,
false /* requires_address_pinning */, 0 /* flags */);
cl_assert_equal_b(shared_prf_storage_get_ble_pairing_data(NULL, NULL, NULL, NULL), true);
... | {
shared_prf_storage_wipe_all();
cl_assert_equal_b(shared_prf_storage_get_root_key(SMRootKeyTypeIdentity, NULL), false);
cl_assert_equal_b(shared_prf_storage_get_root_key(SMRootKeyTypeEncryption, NULL), false);
SM128BitKey keys[2];
for (int i = 0; i < sizeof(keys); ++i) {
((uint8_t *) keys)[i] = i;
}
... |
void test_shared_prf_storage_v3__local_device_name(void) {
cl_assert_equal_b(shared_prf_storage_get_local_device_name(NULL, 0), false);
shared_prf_storage_set_local_device_name(DEVICE_NAME);
char device_name_out[BT_DEVICE_NAME_BUFFER_SIZE];
cl_assert_equal_b(shared_prf_storage_get_local_device_name(device_n... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return ((TestReelData*)kino_reel_custom_get_data(reel))->duration_ms;
} |
static struct TestReelData *test_reel_data;
static KinoReelImpl *test_reel_impl = NULL;
static KinoReel *test_reel = NULL;
static KinoPlayer *test_player = NULL;
// Setup
void test_kino_player__initialize(void) {
test_reel_data = malloc(sizeof(TestReelData));
memset(test_reel_data, 0, sizeof(TestReelData));
s... |
er *header) {
int num_days;
if (header->all_day) {
num_days = header->duration ? (header->duration + MINUTES_PER_DAY - 1) / MINUTES_PER_DAY : 1;
} else {
// The span is the time between 0:00 on the first day of the event
// and 24:00 on the last day of the event
const time_t start_span = time_util... | info->get_val(file, (uint8_t *)&header, sizeof(CommonTimelineItemHeader)) | ;
// Flags & Status are stored inverted.
header.flags = ~header.flags;
header.status = ~header.status;
prv_add_nodes_for_serialized_item(list_head, &header);
return true; // continue iteration
}
static void prv_set_indices(TimelineNode *timeline) {
TimelineNode *node = timeline;
int index = 0;
while (... |
/*
* 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(attr1) | ;
cl_assert_equal_i(attr1->id, VEAttributeIdTranscription);
cl_assert_equal_i(attr1->length, 0x2F);
size_t offset = sizeof(GenericAttributeList) + sizeof(GenericAttribute);
cl_assert_equal_p(attr1->data, &data1[offset]);
GenericAttribute *attr2 = generic_attribute_find_attribute(attr_list1, VEAttributeIdAppU... |
---
// Clear all handler history
static void prv_clear_handler_histories(void) {
memset(&s_started_handler_calls, 0, sizeof(AnimTestHandlerHistory));
memset(&s_stopped_handler_calls, 0, sizeof(AnimTestHandlerHistory));
memset(&s_setup_handler_calls, 0, sizeof(AnimTestHandlerHistory));
memset(&s_teardown_handler... | prv_add_handler_entry(&s_stopped_handler_calls, animation, finished, context) | ;
if (s_stopped_handler_calls.num_calls == 1) {
DPRINTF("%"PRIu64" ms: Rescheduling from stopped handler for %d\n", prv_now_ms(),
(int)animation);
animation_schedule(animation);
} else {
DPRINTF("%"PRIu64" ms: NOT rescheduling from stopped handler for %d\n", prv_now_ms(),
(int)a... |
ifConfig {
InsightStateCommon *state;
ActivityInsightType insight_type;
ActivitySettingsKey settings_key;
TimelineResourceId icon;
const char *text_body;
const char *text_positive_action;
const char *text_neutral_action;
const char *text_negative_action;
const char *text_positive_response;
const cha... | ("Resting is fine, but try to recover and step it up tomorrow!") | ,
.detail_text = i18n_noop("NOT VERY ACTIVE"),
},
}
};
static char s_sleep_period_buffer[SUBTITLE_BUFFER_LENGTH] = "";
static const SummaryPinConfig SLEEP_SUMMARY_PIN_CONFIG = {
.insight_settings = &s_sleep_summary_settings,
.short_title = i18n_noop("Sleep Summary"),
.short_subtitle = s_pin_subtitle_... |
eStateAwaitingResetCompleteRemoteInitiated);
RCV_RESET_COMPLETE();
cl_assert_equal_i(rocky_api_app_message_get_state(), PostMessageStateSessionOpen);
}
void test_rocky_api_app_message__awaiting_reset_complete_loc_init__rcv_chunk(void) {
prv_init_and_goto_awaiting_reset_complete_local_initiated();
RCV_DUMMY_... | prv_simulate_transport_connection_event(true /* is_connected */) | ;
ASSERT_JS_GLOBAL_EQUALS_I("c", 0);
ASSERT_JS_GLOBAL_EQUALS_I("d", 1);
prv_postmessageconnected_postmessagedisconnected_negotiate_to_open_session();
ASSERT_JS_GLOBAL_EQUALS_I("c", 1);
ASSERT_JS_GLOBAL_EQUALS_I("d", 1);
// Get a ResetComplete (unexpected message), should trigger initiating (local) ResetReq... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.