prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
aw_1px_non_aa(&context, GPoint(5, 5), GPoint(45, 10)));
setup_test(&context, false, 1, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect(&context, &GRect(10, 20, 40, 10)));
setup_test(&context, false, 1, GColorBlack, GColorBlack, false);
grap... | GPoint(45, 10) | , 2));
#endif
setup_test(&context, true, 2, GColorBlack, GColorBlack, false);
graphics_draw_rect(&context, &GRect(10, 20, 40, 10));
ASSERT_CALLED(prv_draw_rect(&context, &GRect(10, 20, 40, 10)));
setup_test(&context, true, 2, GColorBlack, GColorBlack, false);
graphics_draw_circle(&context, GPoint(50, 50), 10... |
/*
* 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... | {
p = s2;
while (*p) {
if (s1[len] == *p++) {
return len;
}
}
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... | graphics_fill_radial(ctx, dot_rect, GOvalScaleModeFitCircle, peek_layer->dot_diameter, 0,
TRIG_MAX_ANGLE) | ;
}
}
static void prv_layout_text(PeekLayer *peek_layer) {
const GRect layer_bounds = (GRect) { .size = peek_layer->layer.bounds.size };
GContext *ctx = graphics_context_get_current_context();
text_layer_set_size(&peek_layer->title.text_layer, layer_bounds.size);
text_layer_set_size(&peek_layer->subtitle.tex... |
prv_update_string_and_put_event(artist, artist_length, o) | ;
}
void music_update_track_album(const char *album, size_t album_length) {
off_t o = offsetof(__typeof__(s_music_ctx), album);
prv_update_string_and_put_event(album, album_length, o);
}
static void prv_put_pos_changed_event(void) {
PebbleEvent e = {
.type = PEBBLE_MEDIA_EVENT,
.media.type = PebbleMedia... | |
on_group.actions[0].type, TimelineItemActionTypeGeneric);
cl_assert_equal_i(item->action_group.actions[0].attr_list.num_attributes, 1);
cl_assert_equal_i(item->action_group.actions[0].attr_list.attributes[0].id, AttributeIdTitle);
cl_assert_equal_s(item->action_group.actions[0].attr_list.attributes[0].cstring, "D... | cl_assert_equal_s("c", string_list_get_at(list, 1)) | ;
// 3 strings (last two are is empty)
list->serialized_byte_length = 4;
list->data[0] = 'a';
list->data[1] = 'b';
list->data[2] = '\0';
list->data[3] = '\0'; // end of data
list->data[4] = '\0';
cl_assert_equal_i(3, string_list_count(list));
cl_assert_equal_s("ab", string_list_get_at(list, 0));
cl... |
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... | if (!s_dma_pending_transfer) {
return should_context_switch;
} |
s_dma_pending_transfer = false;
// If the SPI frequency is set low (for debugging) for example 800KHz, it is possible that the
// DMA transfer complete interrupts have fired, but the SPI peripheral is still busy clocking the
// data in/out. With 3.3MHz SPI clock frequency, this is not going to loop at all.
... |
st data, const uint16_t size, void *context) {
struct SerializeTestResult *result = context;
result->okay = true;
result->expected_size = size;
// Read back:
DictionaryIterator iter;
Tuple *tuple = dict_read_begin_from_buffer(&iter, data, size);
cl_assert(tuple != NULL);
cl_assert(iter.dictionary->coun... | (SOME_STRING) | + 1) == 0);
// Check zero termination:
cl_assert(tuple->value->cstring[strlen(SOME_STRING)] == 0);
string_found = true;
break;
case SOME_UINT8_KEY:
cl_assert(tuple->length == sizeof(uint8_t));
cl_assert(tuple->value->uint8 == 8);
uint8_found = true;
... |
/*
* 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_p(strchr(testbuf, '\0'), testbuf+7) | ;
}
void test_strchr__r_basic(void) {
char testbuf[8] = "Hello!B";
cl_assert_equal_p(strrchr(testbuf, 'B'), testbuf+6);
}
void test_strchr__r_unfound(void) {
char testbuf[10] = "Hello!B\0Z";
cl_assert_equal_p(strrchr(testbuf, 'Z'), NULL);
}
void test_strchr__r_big_value(void) {
char testbuf[8] = "Hello!B";... |
;
return &text_layer->layer;
}
void text_layer_set_size(TextLayer *text_layer, const GSize max_size) {
PBL_ASSERTN(text_layer);
layer_set_frame(&text_layer->layer, &(GRect) { text_layer->layer.frame.origin, max_size });
layer_mark_dirty(&text_layer->layer);
}
GSize text_layer_get_size(TextLayer* text_layer) {... | if (text_layer->layer.window == NULL) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Before calling %s, layer must be attached to view hierarchy.",
__func__);
return;
} |
text_layer_set_should_cache_layout(text_layer, true);
graphics_text_attributes_enable_screen_text_flow(text_layer->layout_cache, inset);
GPoint origin;
GRect page;
if (text_layer_calc_text_flow_paging_values(text_layer, &origin, &page)) {
graphics_text_attributes_enable_paging(text_layer->layout_cache,... |
yer *text_layer;
int stress_iteration;
int stress_index;
} FlashStressWindow;
static bool check_region_erased(struct Region region) {
PBL_LOG_SYNC(LOG_LEVEL_INFO, "Checking Erase ...");
bool success = true;
for (uint32_t i = region.begin; i < region.end; i += sizeof(uint32_t)) {
uint32_t read = 0;
f... | (LOG_LEVEL_INFO, ">>>> %s %d", "Test Loop", stress_data.stress_iteration) | ;
PBL_LOG(LOG_LEVEL_INFO, "Erasing 0x%lx to 0x%lx", region.begin, region.end);
flash_region_erase_optimal_range(region.begin, region.begin, region.end, region.end);
bool failed = true;
if (stress_data.stress_index == FILE_WRITE_STRESS) {
failed = (!check_region_erased(region) || !check_region_write(region... |
(key, &uuid_buffer, sizeof(uuid_buffer)), size);
cl_assert(uuid_equal(&test_uuid_a, &uuid_buffer));
}
void test_persist__data_too_big(void) {
char buf[PERSIST_DATA_MAX_LENGTH+2];
memset(buf, '~', sizeof(buf));
cl_assert_equal_i(persist_write_data(0, lipsum, sizeof(lipsum)),
PERSIST_DATA_M... | persist_read_string(0, buffer, 2) | , 2);
cl_assert_equal_i(strlen(buffer), 2 - 1); // -1 because null termination
cl_assert_equal_i(buffer[0], 'H');
// Then attempt to read back the entire thing
cl_assert_equal_i(persist_read_string(0, buffer, sizeof(buffer)), sizeof(buffer));
cl_assert_equal_i(strlen(buffer), 10);
cl_assert(strcmp(buffer, "... |
}
// Parse next set of samples in the current file
bool success = prv_parse_activity_samples_file(state);
if (success) {
*entry = state->test_entry;
return true;
} else {
// No more in this file
fclose(state->common.file);
state->common.file = NULL;
}
}
}
// ---... | {
s_num_captured_activity_sessions++;
} |
}
// ----------------------------------------------------------------------------------------
// Print a timestamp in a format useful for log messages (for debugging). This only prints
// the hour and minute: HH:MM
static const char* prv_log_time(time_t utc) {
static char time_str[8];
int minutes = (utc / SECON... |
(BUTTON_ID_BACK, context) | ;
window_single_click_subscribe(BUTTON_ID_BACK, &prv_mic_click_handler);
window_set_click_context(BUTTON_ID_SELECT, context);
window_single_click_subscribe(BUTTON_ID_SELECT, &prv_mic_click_handler);
}
static void prv_back_click_config_provider(void *context) {
window_set_click_context(BUTTON_ID_BACK, context);... | |
/*
* 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... | protobuf_log_create(&log_config, NULL /*transport*/, 0 /*max_encoded_msg_size*/) | |
ignment_t *)block) + block->Size);
}
//! Move the block pointer back to the previous block.
static HeapInfo_t* get_previous_block(Heap * const heap, HeapInfo_t* block) {
HEAP_ASSERT_SANE(heap, block->PrevSize != 0, block);
return (HeapInfo_t *)(((Alignment_t *)block) - block->PrevSize);
}
static void prv_calc_tot... | HEAP_INFO_BLOCK_SIZE(1) | ) || (allocation_size >= SEGMENT_SIZE_MAX)) {
return NULL;
}
HeapInfo_t* allocated_block;
heap_lock(heap);
{
HeapInfo_t* free_block = find_segment(heap, allocation_size);
allocated_block = allocate_block(heap, allocation_size, free_block);
if (allocated_block != NULL) {
// We've allocat... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_custom_resource_get_index(resource_id) | |
stance_normalized) {
PBL_ASSERTN(!animation_private_using_legacy_2(NULL));
PropertyAnimationPrivate *property_animation = prv_find_property_animation(property_animation_h);
if (!property_animation) {
return;
}
GColor8 result;
result.a = interpolate_int16(
distance_normalized,
property_anim... | implementation->accessors.getter.gpoint(subject) | ;
property_animation->values.from.gpoint = from_value ? *((GPoint*)from_value)
: implementation->accessors.getter.gpoint(subject);
} else if (property_animation->animation.implementation->update
== (AnimationUpdateImplementation)property_animation_u... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | test_graphics_context_reset(ctx, fb) | ;
GDrawState draw_state = {
.clip_box = clip_box,
.drawing_box = drawing_box,
.compositing_mode = compositing_mode,
};
setup_test_context(ctx,
(CTX_FLAG_DS_CLIP_BOX | CTX_FLAG_DS_DRAWING_BOX |
CTX_FLAG_DS_COMPOSITING_MODE),
&draw_state,... |
L_ASSERT(read_length == sizeof(uint8_t), "read_length %u sizeof(uint8_t) %u", read_length, sizeof(uint8_t));
uint8_t msg_length = *data_read;
if (shared_circular_buffer_get_read_space_remaining(&s_buffer, &s_buffer_client) < msg_length + sizeof(uint8_t)) {
return; // Not ready yet, consume nothing.
}
// F... | {
if (s_buffer_mutex == INVALID_MUTEX_HANDLE) {
return;
}
write_buffer_locking(buffer, length, async);
} |
char pbl_log_get_level_char(const uint8_t log_level) {
switch (log_level) {
case LOG_LEVEL_ALWAYS:
return '*';
case LOG_LEVEL_ERROR:
return 'E';
case LOG_LEVEL_WARNING:
return 'W';
case LOG_LEVEL_INFO:
return 'I';
case LOG_LEVEL_DEBUG:
return 'D';
case LOG_LEVEL_DEBUG_VERBOSE:
re... |
Touchdown event occurs, active layer is found and all applicable recognizers receive events
// while none have started recognizing
e.type = TouchEvent_Touchdown;
recognizer_manager_handle_touch_event(&e, &manager);
prv_compare_recognizers_processed((int[]) {4, 0, 3, 1}, 4, &s_recognizers_handled);
cl_assert_e... | recognizer_manager_handle_touch_event(&e, &manager) | ;
prv_compare_recognizers_processed((int[]) {3}, 1, &s_recognizers_handled);
prv_compare_recognizers_processed((int[]) {4, 0, 3, 1}, 4, &s_recognizers_reset);
cl_assert_equal_i(manager.state, RecognizerManagerState_WaitForTouchdown);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_asser... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_create_card_and_render(&config) | ;
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_detail_card__render_subtitle_text(void) {
HealthDetailCardConfig config = {
.num_headings = 1,
.headings = &(HealthDetailHeading) {
.primary_label = "LABEL1",
.primary_value = "value1",
.secondary_label = "L... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (s_emoji_table, "") | == INVALID_RESOURCE);
// Single emoji is detected
cl_check(prv_get_emoji_icon_by_string(s_emoji_table, "😀") ==
RESOURCE_ID_EMOJI_BIG_OPEN_SMILE_LARGE);
// Leading whitespace is ignored
cl_check(prv_get_emoji_icon_by_string(s_emoji_table, " 😀") ==
RESOURCE_ID_EMOJI_BIG_OPEN_SMILE_LARGE... |
e_window;
WorkoutController workout_controller;
AppSync sync;
uint8_t sync_buffer[148];
uint8_t current_bpm;
char duration_string[20];
char distance_string[20];
char pace_string[20];
char custom_label_string[20];
char custom_value_string[20];
bool is_paused;
bool supports_third_party_hr;
Work... | (data->custom_value_string,
new_tuple->value->cstring,
sizeof(data->custom_value_string)) | |
8, -128, -920},
{ 56, -56, -920},
// 253 seconds
{ 56, -56, -904},
{ 64, -64, -928},
{ 48, -24, -960},
{ 56, 32, -936},
{ 56, 32, -952},
{ 48, 0, -928},
{ 40, -24, -928},
{ 48, 8, -936},
{ 40, 8, -936},
{ 48, 24, -928},
{ 48, 0, -944},
{ 48, 8, -936},
{ 48, -8... | { 40, 192, -920},
{ 40, 176, -912},
{ 48, 168, -904},
{ 56, 160, -904},
{ 40, 192, -920},
// 259 seconds
{ 40, 176, -904},
{ 40, 176, -920},
{ 40, 184, -920},
{ 24, 192, -928},
{ 40, 176, -912},
{ 32, 216, -928},
{ 32, 160, -912},
{ 48, 168, -904},
{ -8, 224, ... |
{ 64, 264, -920},
{ 40, 144, -920},
{ 40, 208, -912},
{ 40, 168, -920},
{ 48, 160, -904},
{ 40, 192, -920},
{ 48, 184, -920},
{ 48, 224, -928},
{ 56, 168, -920},
// 262 seconds
{ 72, 208, -928},
{ 40, 72, -888},
{ 56, 120, -928},
{ 56, 120, -936},
{ 48, 56, -... |
/*
* 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;
} |
BTErrno err = gatt_client_op_read(s_app_launch_characteristic, GAPLEClientKernel);
if (err != BTErrnoOK) {
PBL_LOG(LOG_LEVEL_ERROR, "App relaunch failed: %u", err);
}
}
|
ayoutIdGeneric,
.timestamp = 0x53f0dda6,
},
.attr_list = {
.num_attributes = 2,
.attributes = attributes,
},
.action_group = {
.num_actions = 1,
.actions = &actions[2],
}
};
Uuid i3;
uuid_generate(&i3);
TimelineItem e3 = {
.header = {
.id = i3,
... | cl_assert_equal_m(&e3.header, &h, sizeof(CommonTimelineItemHeader)) | ;
}
void test_notification_storage__should_detect_corruption(void) {
Uuid i1;
uuid_generate(&i1);
TimelineItem e1 = {
.header = {
.id = i1,
.type = TimelineItemTypeNotification,
.status = TimelineItemStatusRead,
.ancs_uid = 0,
.layout = LayoutIdGeneric,
.timestamp = 0x53f0... |
/*
* 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_s(app_data.display_name, app_data_out.display_name) | ;
ancs_app_destroy_buffer(&app_data_out);
}
void test_ancs_app_storage__overwrite(void) {
ANCSAppData app_data = {
.bundle_id = "com.getpebble.PebbleApp",
.display_name = "Pebble",
.flags = ANCSAppIsBlocked,
};
app_data.is_meta_changed = true;
ancs_app_storage_save(&app_data);
app_data.displa... |
le = "ConfRM-Missile Command",
.icon = TIMELINE_RESOURCE_TIMELINE_CALENDAR,
.num_concurrent = 0,
}, false /* animated */);
TimelinePeek *peek = timeline_peek_get_peek();
const Layer *layer = &peek->layout_layer;
// Normally it is animated, but for this unit test, we don't request `animated`
cl_assert(... | timeline_peek_set_visible(false, false /* animated */) | ;
// Peek should be hidden and off-screen.
cl_assert(layer->frame.origin.y >= DISP_ROWS);
// Transition back to the watchface
s_is_watchface_running = true;
timeline_peek_set_visible(true, false /* animated */);
// Peek should be visible again, but it should still be off-screen.
cl_assert(layer->frame.or... |
/*
* 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... | (AlertInvalid) | );
cl_assert(!alerts_should_notify_for_type(AlertMobile));
cl_assert(!alerts_should_notify_for_type(AlertReminder));
}
void test_alerts__migration(void) {
cl_assert(alerts_get_mask() == AlertMaskAllOn);
alerts_set_mask(AlertMaskAllOnLegacy);
cl_assert(alerts_get_mask() == AlertMaskAllOn);
}
void test_aler... |
/*
* 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... | {
double val = jerry_get_number_value(argv[0]);
if (!prv_check_value_number_within_bounds(binding->type, &val, value_error_out)) {
return false;
}
if (binding->type != RockyArgTypeDouble && binding->type != RockyArgTypeFixedS16_3) {
val = round(val);
}
void *const dest_ptr = binding->ptr;
switc... | |
ITHOUT 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 "clar.h"
#include "applib/graphics/gtypes.h"
#include "applib/graphics/graphics.h"
#include "applib/graphics/gpath.h"
#include "... | gpath_destroy(s_duplicates_path) | ;
gpath_destroy(s_infinite_path);
gpath_destroy(s_crossing_path);
gpath_destroy(s_aa_clipping_path);
}
// tests
void test_graphics_gpath_${BIT_DEPTH_NAME}__filled(void) {
GContext ctx;
Layer layer;
prv_reset();
s_current_path = s_house_path;
test_graphics_context_init(&ctx, fb);
prv_filled_update_pr... |
///////////////////////////////////////////////////////////////////
// Private interface
void recognizer_handle_touch_event(Recognizer *recognizer, const TouchEvent *touch_event) {
PBL_ASSERTN(recognizer_is_active(recognizer));
PBL_ASSERTN(recognizer->impl);
PBL_ASSERTN(touch_event);
if (!prv_should_handle_to... | {
return;
} | |
required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#in... | write_register(RegPwmOut5, green) | |
TRIC_HISTORY(ActivityMetricSleepRestfulSeconds,
((const uint32_t [ACTIVITY_HISTORY_DAYS])
{3 * SECONDS_PER_MINUTE, 2 * SECONDS_PER_MINUTE,
1 * SECONDS_PER_MINUTE, 0, 0, 0, 0}));
}
// ------------------------------------... | stat(in_path, &st) | == 0);
FILE *file = fopen(in_path, "r");
cl_assert(file);
uint8_t buf[st.st_size];
// copy file to fake flash storage
cl_assert(fread(buf, 1, st.st_size, file) > 0);
pfs_remove(pfs_name);
int fd = pfs_open(pfs_name, OP_FLAG_WRITE, FILE_TYPE_STATIC, st.st_size);
cl_assert(fd >= 0);
int bytes_writte... |
/*
* 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_ERROR, "Received error response.") | ;
return false;
}
*level = response->payload[0];
kernel_free(response);
return true;
}
static void prv_log_string_v1(BinLogMessage_String_v1 *msg) {
PBL_LOG(LOG_LEVEL_ALWAYS, "%s", msg->string);
}
#if PBL_LOGS_HASHED
static void prv_log_param_v1(BinLogMessage_Param_v1 *msg) {
// HACK ALERT: we want t... |
handler_calls, b), 0);
cl_assert_equal_i(prv_count_handler_entries(&s_update_handler_calls, b), 0);
// Complete sequence
prv_advance_to_ms_with_timers(start_ms + duration_a + duration_b + 5 * MIN_FRAME_INTERVAL_MS + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 0);
cl_assert_e... | cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, c), 1) | ;
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, c), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, d), 1)... |
, &callbacks);
}
// helper macro to avoid source code duplication
// we call this instead of a true function to keep the stack as low as possible as this is
// on a critical path.
#define APP_TEXT_GET_CONTENT_SIZE(text, font, box, overflow_mode, alignment, text_attributes) \
do { \
GContext* ctx = app_state_get_... | (TextLayoutExtended) | ;
*((TextLayoutExtended*) *layout) = (TextLayoutExtended) { 0 };
}
}
void graphics_text_layout_cache_deinit(GTextLayoutCacheRef* layout) {
TextLayout* text_layout = (TextLayout*) *layout;
applib_free(text_layout);
*layout = NULL;
}
GTextAttributes *graphics_text_attributes_create(void) {
GTextAttributes... |
MMMMMMMMMMMMMMM"
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"
"MMMMMMMMMMMMMMM... | window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_dialog_load,
.unload = prv_dialog_unload,
.appear = prv_dialog_appear,
}) | ;
window_set_user_data(window, new_dialog);
dialog_push(new_dialog, stack);
}
#endif
static char s_text_test_str[1024];
static void prv_perftest_test_main(void *data) {
profiler_init();
GFont font = fonts_get_system_font(s_perftest_text_arguments.font_key);
int text_index;
int font_index;
if (strcmp(s_... |
);
for (int i = 0; bytes_free > 0 && i < ARRAY_LENGTH(write_sb); ++i) {
size_t payload_length = 1;
bytes_free -= sizeof(PebbleProtocolHeader) + payload_length;
// If we cannot fit another message after this one, increment the length to use up the space:
if (bytes_free <= (sizeof(PebbleProtocolHeade... | comm_session_send_buffer_begin_write(&s_session, ENDPOINT_ID,
1 /* required_free_length */,
TIMEOUT_MS) | |
for (volatile int i = 0; i < 48; i++);
gpio_output_set(&BOARD_CONFIG_DISPLAY.cs, false);
// hold time > 1us
// this produces a delay of ~3.5us
for (volatile int i = 0; i < 16; i++);
}
static void prv_display_start(void) {
periph_config_acquire_lock();
gpio_af_init(&BOARD_CONFIG_DISPLAY.clk, GPIO_OType... | power_tracking_start(PowerSystemMcuDma1) | |
;
if (!app_install_get_entry_for_install_id(install_id, &entry) ||
prv_is_app_filtered_out(&entry, source)) {
return;
}
add_app_with_install_id(&entry, source);
prv_alert_data_source_changed(source);
}
//! Called when an application is installed
static void prv_app_added_callback(const AppInstallId ... | if (node->icon && node->icon != source->default_icon) {
gbitmap_destroy(node->icon);
node->icon = NULL;
} |
}
static void prv_load_list_if_needed(AppMenuDataSource *source) {
if (source->is_list_loaded) {
return;
}
source->is_list_loaded = true;
PBL_ASSERTN(!source->order_storage);
source->order_storage = app_order_read_order();
app_install_enumerate_entries(prv_app_enumerate_callback, source);
app_fre... |
/*
* 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 ((next->timestamp > current_end) && (current->current_day == next->current_day)) {
// Next pin starts after the end of the current pin
return RelationshipBarTypeFreeTime;
} else if ((next->timestamp == current_end) && (current->current_day == next->current_day)) {
// Next pin starts exactly at the end ... |
}
static void prv_rel_bar_stopped(Animation *animation, bool is_finished, void *context) {
// Don't show the rel bar if the animation was interrupted
if (!is_finished) {
TimelineLayer *layer = (TimelineLayer *)context;
prv_rel_bar_reset_offsets(&layer->relbar_layer, RelationshipBarOffsetTypeBoth);
}
}
... |
TION(test_func_imp) {
++s_test_func_imp_call_count;
return jerry_create_undefined();
}
JERRY_FUNCTION(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_... | (getDate, now, NULL, 0) | ;
cl_assert(jerry_get_number_value(result_seconds) == 51.0);
cl_assert(jerry_get_number_value(result_minutes) == 40.0);
cl_assert(jerry_get_number_value(result_hours) == 21.0);
cl_assert(jerry_get_number_value(result_date) == 17.0);
jerry_release_value(result_date);
jerry_release_value(result_hours);
je... |
ten_data);
free(flash_written_flag);
}
void test_system_flash__erase_zero_bytes(void) {
cl_assert(system_flash_erase(FLASH_BASE, 0, NULL, NULL));
cl_assert_equal_i(0, erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_one_byte(void) {
cl_assert(system_flash_erase(FLASH_BASE, 1, NULL, N... | (flash_locked) | ;
assert_flash_unwritten(0, 10);
}
extern void FLASH_Lock(void) {
flash_locked = true;
}
extern void FLASH_Unlock(void) {
flash_locked = false;
}
extern void FLASH_ClearFlag(uint32_t FLASH_FLAG) {
flash_flags_set = false;
}
extern FLASH_Status FLASH_EraseSector(uint32_t sector, uint8_t voltage_range) {
//... |
display_mode_one_item(void) {
static const char* thin_values[] = { "Y" };
ActionMenuLevel *root_level = action_menu_level_create(ARRAY_LENGTH(thin_values));
action_menu_level_set_display_mode(root_level, ActionMenuLevelDisplayModeThin);
for (size_t i = 0; i < ARRAY_LENGTH(thin_values); i++) {
action_menu_le... | action_menu_level_add_child(root_level, template_level,
"Reply to HUBERT BLAINE WOLFESCHLEGELSTEINHAUSENBERGERDORFF") | ;
ActionMenuLevel *emoji_level = action_menu_level_create(1);
action_menu_level_add_action(emoji_level,
"This won't be seen",
prv_noop_action_callback,
NULL);
action_menu_level_add_child(root_level, emoji_level, "Open on... |
/*
* 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... | connection_get_idx(connection) | |
ender_ready();
cl_assert_equal_i(s_count_display_update, 1);
}
void test_compositor__app_not_ready_modal_push_pop(void) {
// If a modal window is popped revealing an app that has not yet rendered itself for the first
// time we shouldn't render the app immediately. We need to still wait for the app to render
/... | cl_assert_equal_i(s_render_pending, true) | ;
// Finish the animation
s_animation_implementation->teardown((Animation*) (uintptr_t) s_count_animation_create);
// App should be free to render again
cl_assert_equal_i(s_render_pending, 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... | strftime(buf, buf_size, "%M", &good_data) | ;
if (r == 0 || strncmp(buf, "04", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"M\": %s", buf);
}
r = strftime(buf, buf_size, "%p", &good_data);
if (r == 0 || strncmp(buf, "AM", buf_size) != 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Error with \"p\": %s", buf);
}
r = strftime(buf, buf_siz... |
assert_equal_i(fake_event_get_count(), 3);
cl_assert(!prv_get_calendar_ongoing());
cl_assert(!stub_new_timer_is_scheduled(timer_id));
}
void test_calendar__init_with_ongoing_event(void) {
cl_assert(timeline_add(&item1));
timeline_event_handle_blobdb_event();
rtc_set_time(15 * 60);
timeline_event_init();
... | (!prv_get_calendar_ongoing()) | ;
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(65*60, stub_new_timer_timeout(timer_id) / 1000);
rtc_set_time(100 * 60);
cl_assert(stub_new_timer_fire(timer_id));
cl_assert_equal_i(fake_event_get_count(), 5);
cl_assert(prv_get_calendar_ongoing());
cl_assert(stub_new_timer_is_schedul... |
icSleepStateSeconds, 1, &sleep_seconds);
return rv ? sleep_seconds : 0;
#else
return 0;
#endif
}
// ----------------------------------------------------------------------------------------------
static int32_t prv_get_vmc(void) {
#if CAPABILITY_HAS_HEALTH_TRACKING
int32_t vmc;
const bool rv = activity_get_metr... | {
// If an alarm was updated then remove all the pins with stale information
// If an alarm was added then this has no effect
bool updated = prv_timeline_remove_alarm(file, alarm->id);
// We allocate some larger variables on the heap to reduce stack usage
struct tm *local_alarm_time = kernel_malloc_check(siz... |
settings_file_buffer, UUID_SIZE * num_pin_adds);
cleanup:
kernel_free(settings_file_buffer);
kernel_free(local_alarm_time);
kernel_free(entry);
}
// ----------------------------------------------------------------------------------------------
static time_t prv_build_cron(AlarmConfig *confi... |
/*
* 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... | GRect(0, 0, DISP_COLS, DISP_ROWS) | |
int key_i = atoi((char*)key + 1);
cl_assert(key_i >= 0 && key_i < 255);
uint8_t *cur_val = (uint8_t*)context;
*cur_val = key_i;
int val_i = atoi((char*)val + 1);
cl_assert_equal_i(key_i, val_i);
if (key_i == STOPPING_NUM) {
return false;
}
return true;
}
void test_settings_file__each_quit_ear... | (&file.iter) | ;
// Get the iter to the record we want
cl_assert_equal_b(true, settings_file_exists(&file, key, key_len));
// Check that we can do a get_len and we don't search past the current record
int before_count = settings_raw_iter_prv_get_num_record_searches();
cl_assert_equal_i(key_len, settings_file_get_len(&file... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
ASSERT_JS_GLOBAL_EQUALS_I("num_times", d);
cl_assert(fake_app_timer_is_scheduled(timer));
cl_assert(app_timer_trigger(timer));
ASSERT_JS_GLOBAL_EQUALS_I("extra_arg", 5.0);
} |
script = "clearInterval(timer);";
EXECUTE_SCRIPT(script);
cl_assert(fake_app_timer_is_scheduled(timer) == false);
}
void test_rocky_api_timers__setTimeout(void) {
char *script =
"var num_times = 0;"
"var f = function(extra) {"
" num_times++;"
"};"
"var timer = setTimeout('f()',... |
(op & StatsBasicOp_ConsecutiveFirst);
for (size_t i = 0; i < num_data; i++) {
const int32_t value = data[i];
if (filter && !filter(i, value, context)) {
if (op & StatsBasicOp_Consecutive) {
if (consecutive_current > consecutive_max) {
consecutive_max = consecutive_current;
}
... | {
tmp_sum -= values[k].weight_x100;
// Have to modulo since we need to know if this is *exact*. Integer division will not let us
// know if this is exact if it is an odd number.
if ((S_x100 % 2 == 0) && tmp_sum == (S_x100 / 2)) {
// This is a `tie`
rv = (values[k].value + values[k + 1].valu... | |
registry) {
for (int i = 0; i < registry->num_records; i++) {
Record* r = registry->records + i;
if (r->active) {
if (record_compare(r, key, key_length, uuid)) {
return i;
}
}
}
return -1;
}
Record* registry_private_get(const char* key, const uint8_t key_length,
... | PBL_LOG(LOG_LEVEL_DEBUG, "Writing registry to flash...") | ;
prv_assert_valid_cursor(registry->cursor);
// Mark the previous registry as invalid
registry_set_header(registry->cursor->address, false);
// Erase the spot for the next registry and write to it
prv_write_next_registry(registry);
registry->is_different_from_flash = false;
}
void registry_private_init... |
/*
* 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... | GColorARGB8FromHEX(0x00ffff) | },
{"antiquewhite", GColorARGB8FromHEX(0xfaebd7)},
{"aquamarine", GColorARGB8FromHEX(0x7fffd4)},
{"azure", GColorARGB8FromHEX(0xf0ffff)},
{"beige", GColorARGB8FromHEX(0xf5f5dc)},
{"bisque", GColorARGB8FromHEX(0xffe4c4)},
{"blanchedalmond", GColorARGB8FromHEX(0xffebcd)},
{"blueviolet", GColorARGB8FromHEX(0... |
{ 352, 136, -120},
{ 392, 136, -88},
{ 592, 240, -120},
{ 904, 288, -192},
{ 1128, 480, -248},
{ 1176, 648, -232},
{ 1208, 584, -144},
{ 1312, 616, -120},
{ 1120, 568, -120},
{ 1048, 440, -104},
{ 1056, 424, -88},
{ 1008, 408, -24},
{ 856, 304, 16},
{ 712, 216, 8},... | { 1056, 192, -128},
{ 1112, 176, -64},
{ 1112, 208, -88},
{ 920, 240, -104},
// 13 seconds
{ 616, 216, -96},
{ 440, 160, -112},
{ 392, 152, -96},
{ 480, 184, -88},
{ 664, 200, -128},
{ 960, 192, -192},
{ 1224, 200, -192},
{ 1232, 432, -248},
{ 1224, 464, -240},
... |
{ 576, 216, -120},
{ 864, 248, -144},
{ 1240, 328, -192},
{ 1176, 400, -304},
{ 1216, 392, -248},
{ 1360, 440, -232},
{ 1120, 400, -160},
{ 920, 336, -120},
{ 1056, 376, -104},
{ 1192, 360, -40},
{ 1016, 264, 0},
{ 768, 192, 16},
// 16 seconds
{ 592, 240, -32},
... |
m_actions = ARRAY_LENGTH(actions),
.actions = actions,
}
};
Uuid i2;
uuid_generate(&i2);
TimelineItem e2 = {
.header = {
.id = i2,
.type = TimelineItemTypeNotification,
.status = 0,
.ancs_uid = 0,
.layout = LayoutIdGeneric,
.timestamp = 0x53f0dda6,
},
.... | free(r.allocated_buffer) | ;
// Fill up storage again
for (++i; i < count + erase_count; i++) {
e.header.id = uuids[i % count];
e.header.timestamp = timestamp + i;
notification_storage_store(&e);
cl_assert(notification_storage_get(&uuids[i % count], &r));
compare_notifications(&e, &r);
free(r.allocated_buffer);
}
... |
if (set) {
dest[dest_x] = GColorBlack.argb;
}
}
break;
case GCompOpSet:
for (int i = src_start_idx; i < src_end_idx; ++i, ++dest_x) {
const uint32_t bit = (1 << i);
const bool set = src & bit;
if (!set) {
... | bitblt_bitmap_into_bitmap_tiled_1bit_to_8bit(dest_bitmap, src_bitmap, dest_rect,
src_origin_offset, compositing_mode,
tint_color) | |
ribute_find(¬if_prefs->attr_list, AttributeIdShortTitle);
cl_assert(title);
cl_assert_equal_s(title->cstring, "Title");
Attribute *mute = attribute_find(¬if_prefs->attr_list, AttributeIdMuteDayOfWeek);
cl_assert(mute);
cl_assert_equal_i(mute->uint8, 0x1F);
Attribute *name = attribute_find(¬if_prefs... | (&is_dirty) | , S_SUCCESS);
cl_assert(!is_dirty);
dirty_list = ios_notif_pref_db_get_dirty_list();
cl_assert(!dirty_list);
}
|
e(void) {
GDrawCommandSequence *sequence;
size_t size = prv_create_test_sequence(&sequence);
cl_assert_equal_i(size, gdraw_command_sequence_get_data_size(sequence));
cl_assert(gdraw_command_sequence_validate(sequence, size));
cl_assert(!gdraw_command_sequence_validate(sequence, size - 1));
cl_assert(!gdraw... | (frame->command_list.num_commands, 1) | ;
command = gdraw_command_list_get_command(&frame->command_list, 0);
cl_assert_equal_i(command->type, GDrawCommandTypePath);
cl_assert_equal_i(command->num_points, 3);
cl_assert_equal_i(command->stroke_color.argb, GColorRedARGB8);
cl_assert_equal_i(command->fill_color.argb, GColorBlackARGB8);
cl_assert_equa... |
er_hrm_service_is_enabled;
static int s_bt_driver_hrm_service_enable_call_count;
void bt_driver_hrm_service_enable(bool enable) {
s_bt_driver_hrm_service_enable_call_count++;
s_bt_driver_hrm_service_is_enabled = enable;
}
static BleHrmServiceMeasurement s_last_ble_hrm_measurement;
static int s_bt_driver_hrm_servic... | cl_assert_equal_p(NULL, info->handler) | ;
}
}
void test_ble_hrm__cleanup(void) {
ble_hrm_deinit();
prv_assert_event_service_subscribed(false);
// hrm manager sub vs unsub calls should be the same, there should be no subscription any more
// after de-initing:
cl_assert_equal_i(s_sys_hrm_manager_unsubscribe_call_count,
s_hrm_m... |
reate_test_inbox_and_begin_write();
cl_assert_equal_b(true, app_inbox_service_write(AppInboxServiceTagUnitTest,
s_test_data, BUFFER_SIZE));
// After ending the write, expect num_success to be incremented by one:
app_inbox_service_end(AppInboxServiceTagUnitTest);
... | app_inbox_service_write(AppInboxServiceTagUnitTest, s_test_data, 1) | );
cl_assert_equal_b(true, app_inbox_service_end(AppInboxServiceTagUnitTest));
// Message 2:
cl_assert_equal_b(true, app_inbox_service_begin(AppInboxServiceTagUnitTest, 1, s_writer));
cl_assert_equal_b(true, app_inbox_service_write(AppInboxServiceTagUnitTest, s_test_data, 1));
cl_assert_equal_b(true, app_inb... |
irk_out;
BTDeviceInternal device_out;
// Store a pairing
SMPairingInfo pairing = (SMPairingInfo) {
.irk = (SMIdentityResolvingKey) {
.data = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00
},
},
.identity = (BTDeviceInternal... | cl_assert_equal_m(&link_key_2, &link_key_out, sizeof(link_key_out)) | ;
cl_assert_equal_s(name_2, name_out);
cl_assert_equal_i(platform_bits_2, platform_bits_out);
// Add a thrid pairing
BTDeviceAddress addr_3 = {.octets = {0x31, 0x32, 0x33, 0x34, 0x35, 0x36}};
SM128BitKey link_key_3 = {
.data = {
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30... |
t(&iterator, &state, &head, TimelineIterDirectionFuture,
s_feb_5_midnight + 11 * 60 * 60), 2);
}
void test_timeline__two_iterators(void) {
uint8_t init_net_allocs = fake_pbl_malloc_num_net_allocs();
Iterator iterator1 = {0};
Iterator iterator2 = {0};
TimelineIterState state1 = {0};
TimelineIterState stat... | (state.node) | |
previous_selection_animation_duration_ms == 0) || (cumulative_elapsed_ms != 0)) {
launcher_app_glance_service_pause_current_glance(service);
launcher_app_glance_service_play_current_glance(service);
}
}
}
static void prv_structured_glance_subtitle_dynamic_text_node_update(
GContext *ctx, GTextNod... | graphics_text_node_create_horizontal(max_horizontal_icon_container_nodes) | ;
horizontal_icon_container_node->horizontal_alignment = GTextAlignmentCenter;
graphics_text_node_container_add_child(&vertical_icon_container_node->container,
&horizontal_icon_container_node->container.node);
GTextNodeCustom *icon_node =
graphics_text_node_create_c... |
c PebbleRecursiveMutex *s_analytics_lock = NULL;
// Locking Functions
static void prv_lock(void) {
mutex_lock_recursive(s_analytics_lock);
}
static void prv_unlock(void) {
mutex_unlock_recursive(s_analytics_lock);
}
// Analytic Node Functions
static bool prv_compare_analytic(ListNode *found_node, void *data) {... | (stopwatch, rtc_get()) | );
list_remove(&stopwatch->node, &s_stopwatch_list, NULL);
}
prv_unlock();
}
void analytics_stopwatches_update(uint32_t current_ticks) {
prv_lock();
ListNode *cur = s_stopwatch_list;
while (cur != NULL) {
AnalyticsStopwatchNode *node = (AnalyticsStopwatchNode *)cur;
analytics_add(node->metric, p... |
essions(data->health_data);
ActivitySession *sessions = health_data_sleep_get_sessions(data->health_data);
for (int i = 0; i < num_sessions; i++) {
ActivitySession *session = &sessions[i];
GColor fill_color = GColorClear;
if (session->type == ActivitySessionType_Sleep) {
fill_color = PROGRESS_CUR... | {
HealthSleepSummaryCardData *data = layer_get_data(base_layer);
// Renders the background
health_progress_bar_fill(ctx, &data->progress_bar, PROGRESS_BACKGROUND_COLOR,
0, HEALTH_PROGRESS_BAR_MAX_VALUE);
prv_render_sleep_sessions(ctx, data);
prv_render_typical_markers(ctx, data);... |
static void prv_render_icon(GContext *ctx, Layer *base_layer) {
HealthSleepSummaryCardData *data = layer_get_data(base_layer);
const int y = PBL_IF_RECT_ELSE(PBL_IF_BW_ELSE(37, 32), 39);
const int x_center_offset = 17;
kino_reel_draw(data->icon, ctx, GPoint(base_layer->bounds.size.w / 2 - x_center_offset, y)... |
/*
* 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... | memory_layout_is_pointer_in_region(®ion, (void*) 1999) | );
cl_assert(!memory_layout_is_pointer_in_region(®ion, (void*) 2000));
cl_assert(!memory_layout_is_pointer_in_region(®ion, (void*) 9999));
}
void test_memory_layout__cstring_in_region(void) {
const char buffer[] = "yyyxxxstrstr\0badstrxxxyyy";
const char *valid_str = buffer + 6; // skip yyyxxx, equal to ... |
te = true;
#if MFG_INFO_RECORDS_TEST_RESULTS
mfg_info_write_test_result(MfgTest_Buttons, test_passed);
#endif
if (test_passed) {
// pass
sniprintf(data->status_string, sizeof(data->status_string), "PASS!");
} else {
// fail
sniprintf(data->status_string, sizeof(data->status_string)... | {
static const PebbleProcessMdSystem s_app_info = {
.common.main_func = &s_main,
// UUID: eed03647-fa9e-4bae-9254-608aa297e4e4
.common.uuid = { 0xee, 0xd0, 0x36, 0x47, 0xfa, 0x9e, 0x4b, 0xae,
0x92, 0x54, 0x60, 0x8a, 0xa2, 0x97, 0xe4, 0xe4},
.name = "MfgButton",
};
return (cons... | |
ode = (AnalyticsNode *)found_node;
return (node->metric == (DialogAnalyticsMetric)data);
}
static AnalyticsNode *prv_find_analytic(DialogAnalyticsMetric metric) {
return (AnalyticsNode *)list_find(
s_analytics_list, prv_compare_analytic, (void *)(uintptr_t)metric);
}
static void prv_add_analytic_node(Dialog... | analytics_add(node->metric, prv_stopwatch_elapsed_ms(node, current_ticks)) | ;
node->starting_ticks = current_ticks;
cur = cur->next;
}
prv_unlock();
}
// Getters
void analytics_each(AnalyticsEachCallback cb, void *context) {
analytics_stopwatches_update(rtc_get());
prv_lock();
ListNode *iter = s_analytics_list;
while (iter) {
AnalyticsNode *node = (AnalyticsNode *)i... |
gorithm_deinit(void) {
return true;
}
void activity_algorithm_handle_accel(AccelRawData *data, uint32_t num_samples, uint64_t timestamp) {
// For testing purposes, we'll use the x movment as the steps and y as the sleep state
ActivitySleepState prior_state = s_test_alg_state.minute_data.sleep_state;
time_t now... | .ongoing = true,
};
} else {
// We were in restful sleep before, we should already have a container
cl_assert(s_test_alg_state.minute_data.sleep_current_container_idx >= 0);
}
break;
// We are entering restful sleep ------------------
case A... |
// Update the rate info
// The actual implementation only sends a rate update once every epoch (5 seconds), so
// emulate that
if ((now_secs - s_test_alg_state.rate_last_update_time) >= 5) {
s_test_alg_state.rate_steps = s_test_alg_state.steps - s_test_alg_state.rate_last_steps;
s_test_alg_state.rate_e... |
k_handle = g_task_handles[task];
if (!task_handle) {
return "Unknown";
}
return (const char*) pcTaskGetTaskName(task_handle);
}
// NOTE: The logging support calls toupper() this character if the task is currently running privileged, so
// these identifiers should be all lower case and case-insensitive.
cha... | {
MpuRegion app_region;
MpuRegion worker_region;
switch (pebble_task) {
case PebbleTask_App:
mpu_init_region_from_region(&app_region, memory_layout_get_app_region(),
true /* allow_user_access */);
mpu_init_region_from_region(&worker_region, memory_layout_get_worke... |
case PebbleTask_KernelMain:
stack_guard_region = memory_layout_get_kernel_main_stack_guard_region();
break;
case PebbleTask_KernelBackground:
stack_guard_region = memory_layout_get_kernel_bg_stack_guard_region();
break;
case PebbleTask_BTCallback:
case PebbleTask_BTRX:
case ... |
flash_lock() | ;
if (!s_flash_state.enabled) {
flash_unlock();
return;
}
flash_prf_set_protection(false);
power_tracking_start(PowerSystemFlashErase);
enable_flash_spi_clock();
handle_sleep_when_idle_begin();
flash_write_enable();
flash_start_cmd();
flash_send_and_receive_byte(FLASH_CMD_ERASE_BULK);
... | |
r = prv_read_status_register(sector_addr);
if ((sr & S29VSStatusBit_DeviceReady) == 0) {
// Another operation is already in progress.
error = E_BUSY;
} else if (sr & S29VSStatusBit_EraseSuspended) {
// Cannot program while another program operation is suspended.
error = E_INVALID_OPERATI... | for (uint32_t words_read = 0; words_read < num_words; words_read++) {
buffer[words_read] = flash_data_region[words_read];
} |
}
// Currently this implementation reads halfwords at a time (16-bits). Burst
// length is currently 1 for synchronous reads. This can be optimized in future
// to do larger burst sizes and/or unrolling larger transfer sizes into 32-bit
// reads.
status_t flash_impl_read_sync(void *buffer_ptr, FlashAddress start_addr... |
, uint8_t out) {
PBL_ASSERTN(slave->slave_state->initialized);
PBL_ASSERTN(slave->slave_state->acquired);
PBL_ASSERTN(slave->slave_state->scs_selected);
prv_spi_transmit_flush_blocking(slave->spi_bus);
prv_spi_send_data(slave->spi_bus, out);
prv_spi_receive_wait_ready_blocking(slave->spi_bus);
return prv_... | dma_request_stop(slave->rx_dma) | ;
PBL_ASSERTN(slave->slave_state->initialized);
PBL_ASSERTN(slave->slave_state->acquired);
prv_spi_dma_cmd(slave->spi_bus, SpiI2sDma_ReqRx, false);
slave->slave_state->dma_complete_handler = NULL;
slave->slave_state->dma_complete_context = NULL;
}
void spi_ll_slave_write_dma_start(const SPISlavePort *slave, ... |
graphics_internal_circle_quadrant_fill_aa(&context, GPoint(50, 50), 10, GCornersAll) | );
#else
ASSERT_CALLED(graphics_circle_fill_non_aa(&context, GPoint(50, 50), 10));
#endif
setup_test(&context, true, 5, GColorBlack, GColorBlack, false);
graphics_fill_round_rect(&context, &GRect(20, 80, 40, 10), 4, GCornersAll);
#if SCREEN_COLOR_DEPTH_BITS == 1
ASSERT_CALLED(prv_fill_rect_non_aa(&context, &GR... | |
/*
* 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 (_clar_path[0] == '\0' && build_sandbox_path() < 0)
return -1; |
if (chdir(_clar_path) != 0)
return -1;
return 0;
}
|
/*
* 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_layer_mark_dirty.call_count++;
s_layer_mark_dirty.last_call = (MockCallRecording){.layer = layer};
} | |
IONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/graphics/gtypes.h"
#include "applib/graphics/bitblt.h"
#include "clar.h"
#include "util.h"
#include <string.h>
#include <stdio.h>
// Stubs
//////... | (native_framebuffer, bitmap, GPointZero, GCompOpAssign, GColorWhite) | ;
cl_assert(gbitmap_pbi_eq(native_framebuffer, TEST_PBI_FILE));
}
// Tests 8-bit bitblt tiling support to circular display buffer
// Result:
// - gbitmap matches platform loaded PBI
void test_bitblt_circular__color_8_bit_tiling(void) {
GBitmap *bitmap = setup_png_test(TEST_NAMED_PNG_FILE("test_bitblt_circular__t... |
n *prop_h;
int16_t value = 0;
int16_t start_value = 0, end_value = 100;
const int duration = 200;
const int delay = 25;
const AnimationHandlers handlers = {
.started = prv_started_handler,
.stopped = prv_stopped_handler
};
static const PropertyAnimationImplementation implementation = {
.base... | (&implementation, &value, &start_value, &end_value) | |
GColorARGB8FromHEX(0xda70d6) | },
{"palegoldenrod", GColorARGB8FromHEX(0xeee8aa)},
{"palegreen", GColorARGB8FromHEX(0x98fb98)},
{"paleturquoise", GColorARGB8FromHEX(0xafeeee)},
{"palevioletred", GColorARGB8FromHEX(0xdb7093)},
{"papayawhip", GColorARGB8FromHEX(0xffefd5)},
{"peachpuff", GColorARGB8FromHEX(0xffdab9)},
{"peru", GColorARGB8... | |
NINITIALIZED");
// Forward declarations
static bool prv_realloc_storage(DataLoggingSession *session, uint32_t new_size);
static bool prv_get_session_file(DataLoggingSession *session, uint32_t space_needed);
static void prv_release_session_file(DataLoggingSession *session);
// ----------------------------------------... | {
*size_p += prv_pfs_get_file_size(session->storage.fd);
prv_release_session_file(session);
} | |
across_y_offset_layer")));
test_graphics_context_reset(&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_offset_layer")));
}
void test_graphics_draw_line__clear... | // Odd rows of different lengths
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 1), MAX_NUM_COLS);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 3), 148);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 5), 0);
... |
for (int16_t row = 0; row < MAX_NUM_ROWS; row++) {
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, row), MAX_NUM_COLS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_origin_even_clip")));
// Clipping on odd boundaries - no offset
setup_test_aa_sw(&c... |
// +-parent
// |
// '->child_b->child_a
//
layer_insert_below_sibling(&child_b, &child_a);
cl_assert(child_b.parent == &parent);
cl_assert(child_b.next_sibling == &child_a);
cl_assert(child_a.next_sibling == NULL);
// Insert child_c below child_a (next_sibling code path):
//
// +-parent
/... | cl_assert_equal_i(1, current_stack);
cl_assert_equal_p(a, stack[0]);
cl_assert_equal_p(ab, stack[1]);
// go back one level and then to sibling
actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), ¤t_stack, true);
cl_assert_equal_p(b, actual);
cl_assert_equal_i(0, current_s... |
void test_layer__is_ancestor(void) {
Layer parent, child_a, child_b, child_c;
Layer *layers[] = {&parent, &child_a, &child_b, &child_c};
for (int i = 0; i < ARRAY_LENGTH(layers); ++i) {
layer_init(layers[i], &GRectZero);
}
layer_add_child(&parent, &child_a);
cl_assert(layer_is_descendant(&child_a, &p... |
sticData],
BLESubscriptionNotifications, BLEGATTErrorSuccess);
// Expect Reset to be initiated ("Reset Request" sent by FW):
prv_assert_sent_reset_request(s_characteristics[0][PPoGATTCharacteristicData]);
// Receive data:
prv_receive_short_data_fragment(s_characteristics[0][PPoGATTC... | cl_assert_equal_b(fake_comm_session_send_buffer_write_raw_by_transport(transport,
s_short_data_fragment,
sizeof(s_short_data_fragment)), true) | ;
ppogatt_send_next(transport);
fake_gatt_client_op_assert_no_write();
// Ack the first one (sn=0):
prv_receive_ack(s_characteristics[0][PPoGATTCharacteristicData], 0 /* sn */);
// The last enqueued one should now be sent out:
prv_assert_sent_data(s_characteristics[0][PPoGATTCharacteristicData], sn,
... |
{ -48, -96, -968},
{ -48, -112, -960},
{ -48, -104, -952},
{ -40, -104, -960},
{ -56, -120, -960},
{ -48, -104, -952},
{ -40, -96, -952},
{ -48, -96, -968},
{ -48, -88, -968},
{ -40, -96, -952},
{ -32, -72, -984},
{ -56, -88, -912},
{ -80, -56, -992},
{ -64, -112, -... | { -40, -216, -944},
{ -24, -208, -960},
{ -16, -208, -968},
{ -8, -184, -968},
{ -8, -160, -976},
{ -16, -144, -936},
{ -8, -144, -952},
{ -32, -144, -960},
{ -32, -152, -936},
{ -24, -144, -952},
{ -32, -152, -960},
{ -32, -152, -952},
{ -24, -160, -960},
{ -24, ... |
{ -32, -120, -960},
{ -32, -120, -952},
{ -40, -112, -960},
{ -48, -120, -960},
{ -40, -120, -952},
{ -40, -120, -952},
{ -32, -120, -960},
{ -32, -104, -960},
{ -40, -104, -952},
{ -40, -112, -960},
{ -32, -112, -952},
{ -32, -112, -960},
{ -32, -104, -968},
{ -... |
*is_data = (client->characteristics.data == characteristic);
}
return client;
}
// -------------------------------------------------------------------------------------------------
static bool prv_uuid_filter_callback(ListNode *found_node, void *data) {
const PPoGATTClient *client = (const PPoGATTClient *) f... | // TODO: For larger MTU sizes, we wind up getting throttled by default_kernel_sender.c
// because it limits kernel heap space allocated to ~1kB. We may be able to improve App
// Message throughput by fiddling with this value but at the same time we run a higher risk
// of blowing up the Dialog H... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (this->state->link_state == LinkState_Opened) {
struct LCPPacket *reply = pulse_link_send_begin(this->protocol_number);
memcpy(reply, packet, ntoh16(packet->length));
reply->code = ControlCode_EchoReply;
pulse_link_send(reply, ntoh16(packet->length));
} | |
riting, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "board/board.h"
#include "drivers/acces... | if (errors.error_mask != 0) {
uint16_t dr = uart_read_byte(BT_RX_BOOTROM_UART);
// The Dialog bootROM attempts to talk several serial protocols. While doing this it will
// reconfigure gpios as inputs and outputs and change what data it is pushing on the lines.
// For some architectures, this c... |
if (uart_is_rx_ready(BT_RX_BOOTROM_UART)) {
*char_received = uart_read_byte(BT_RX_BOOTROM_UART);
return true;
}
} while (rtc_get_ticks() <= end_ticks);
PBL_LOG(LOG_LEVEL_ERROR, "Timed out waiting for char");
return false;
}
static bool prv_bootrom_wait_for_char(char *char_received) {
con... |
that from higher latency requests, but most of
// the time we should be in the maximum latency (low power) state anyway
// get & set the new state
prv_handle_response_latency_for_le_conn(hdl);
unlock:
bt_unlock();
}
static void prv_bt_le_gateway_response_latency_watchdog_cb(void *data) {
// offload handli... | (watchdog_cb_info) | ;
}
ListNode *curr_request = (ListNode *)(*info)->requests;
while (curr_request != NULL) {
ListNode *temp = list_get_next(curr_request);
list_remove(curr_request, NULL, NULL);
kernel_free(curr_request);
curr_request = temp;
}
kernel_free(*info);
*info = NULL;
}
void command_change_le_mode... |
ule_all_in_update_handler_without_auto_destroy(void) {
prv_unschedule_all_in_update_handler(false);
}
static void prv_stopped_unschedule_all_handler(Animation *animation, bool finished, void *context) {
prv_add_handler_entry(&s_stopped_handler_calls, animation, finished, context);
DPRINTF("%"PRIu64" ms: Executin... | prv_create_test_animation() | |
//--------------------------------------------------------------------------------
// Running Tests
//--------------------------------------------------------------------------------
// Running the actual test is an asynchronous operations which expects a
// callback to come from the bt test driver.
// We keep track of... | {
failed = true;
goto cleanup;
} |
}
#endif
if (!prv_run_test_step(BTLETestStep_BTStart, data)) {
failed = true;
goto cleanup;
}
switch (data->current_test) {
case BTLETestType_TX:
if (!prv_run_test_step(BTLETestStep_BTLETransmitStart, data)) {
failed = true;
goto cleanup;
}
break;
case BTLETe... |
zr = (305 * d[i].z + 305 * zp + 9391 * zr) / 10000;
xp = d[i].x; yp = d[i].y; zp = d[i].z;
x += xr;
y += yr;
z += zr;
}
x /= (int)num_samples;
y /= (int)num_samples;
z /= (int)num_samples;
// TODO: could this ever be called in the middle of ecompass_service_handle?
// map accel da... | (MagSampleRate20Hz) | ;
regular_timer_add_multiminute_callback(&s_cb_info, 2);
s_calib_run = true;
s_high_freq_calib_active = true;
samples_collected = 0;
return; // if we are switching to high freq mode, don't use 1st sample
}
if (samples_collected < 5) {
return; // wait a few samples for ramp u... |
_apply_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... | cl_assert(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 *... |
is_highlighted = is_selected;
s_cell_is_highlighted = is_selected;
const MenuCellLayerConfig config = {
.title_font = column_data->title_font ? fonts_get_system_font(column_data->title_font) : NULL,
.subtitle_font = column_data->subtitle_font ? fonts_get_system_font(column_data->subtitle_font) : NULL,
... | (s_dest_bitmap, TEST_PBI_FILE) | );
#endif
}
void test_menu_layer_system_cells__basic_cell_width_144(void) {
const int16_t cell_width = 144;
prv_prepare_canvas_and_render_cells(
MenuCellType_Basic, cell_width,
s_menu_system_basic_cell_test_column_data,
ARRAY_LENGTH(s_menu_system_basic_cell_test_column_data),
/* is_legacy2 ... |
ection:
cl_assert_equal_i(gap_le_connect_connection_intents_count(), 0);
}
void __disabled_test_gap_le_connect__two_clients_one_without_autoreconnect(void) {
BTDeviceInternal device = prv_dummy_device(1);
// Register auto-reconnecting connection intent for kernel:
gap_le_connect_connect(&device,
... | gap_le_connect_cancel_by_bonding(bonding_id, GAPLEClientApp) | ;
cl_assert_equal_i(e, BTErrnoOK);
prv_assert_no_event();
// Verify there are no more intents:
cl_assert_equal_i(gap_le_connect_connection_intents_count(), 0);
cl_assert_equal_b(gap_le_connect_has_pending_create_connection(), false);
}
void test_gap_le_connect__slave_disconnection_event_upon_cancel_connect... |
;
static void main_task(void *parameter);
static void print_splash_screen(void)
{
#if defined(MANUFACTURING_FW)
PBL_LOG(LOG_LEVEL_ALWAYS, "__TINTIN__ - MANUFACTURING MODE");
#elif defined(RECOVERY_FW)
PBL_LOG(LOG_LEVEL_ALWAYS, "__TINTIN__ - RECOVERY MODE");
#else
PBL_LOG(LOG_LEVEL_ALWAYS, "__TINTIN__");
#endif... | (PWR, RCC_APB1Periph_PWR) | ;
pwr_flash_power_down_stop_mode(true /* power_down */);
periph_config_disable(PWR, RCC_APB1Periph_PWR);
vTaskStartScheduler();
for(;;);
}
static void watchdog_timer_callback(void* data) {
task_watchdog_bit_set(PebbleTask_NewTimers);
}
static void vcom_timer_callback(void* data) {
display_pulse_vcom();
}... |
/*
* 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_snprintf(str, STR_SIZE, "%s%f%s", "a", 1.0, "b") | ;
cl_assert_equal_s(str, fp_msg);
pbl_snprintf(str, STR_SIZE, "%s%d%s", "a", 1, "b");
cl_assert_equal_s(str, "a1b");
//----------------------------------------------------
pbl_snprintf(str, STR_SIZE, "abc%s %0.1f%s", "a", 1.0, "b");
cl_assert_equal_s(str, fp_msg);
pbl_snprintf(str, STR_SIZE, "abc%s %d%s"... |
int32_t new_address =
round_up_to_nearest_subsector(old_address + registry->total_buffer_size_bytes);
const bool is_space_for_registry =
new_address + registry->total_buffer_size_bytes < registry->cursor->end;
if (is_space_for_registry) {
return new_address;
}
return registry->cursor->begin;
... | {
return true;
} |
return false;
}
static int record_get_index(const char* key, const uint8_t key_length, const uint8_t* uuid, Registry* registry) {
for (int i = 0; i < registry->num_records; i++) {
Record* r = registry->records + i;
if (r->active) {
if (record_compare(r, key, key_length, uuid)) {
return i;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.