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...
{ PBL_LOG(LOG_LEVEL_DEBUG, "Discovery Complete, status = 0x%x", payload->status); GAPLEConnection *connection = gap_le_connection_by_device(&payload->address); if (connection == NULL) { PBL_LOG(LOG_LEVEL_WARNING, "Discovery complete but no device connected?"); return; } BTErrno e = (payload->status =...
static void prv_handle_discover_service_changed_handle( HcProtocolDiscoveryServiceChangedHandlePayload *payload) { GAPLEConnection *connection = gap_le_connection_by_device(&payload->address); if (connection == NULL) { PBL_LOG(LOG_LEVEL_WARNING, "Discovery service_changed_handle but no device connected?")...
v_add_event_listener_to_list((char *)event_name, func); return jerry_create_undefined(); } JERRY_FUNCTION(prv_remove_event_listener) { char event_name[32]; jerry_value_t func; // out parameter &func will not be acquired JS_VAR arg_result = prv_event_listener_extract_args(argc, argv, ...
(prv_call_event_handlers_async_cb, (void *)(uintptr_t)jerry_acquire_value(event))
; } jerry_value_t rocky_global_create_event(const char *type_str) { JS_VAR jerry_type_str = jerry_create_string_utf8((const jerry_char_t *)type_str); JS_VAR event = rocky_create_with_constructor(ROCKY_EVENT_CONSTRUCTOR, &jerry_type_str, 1); return jerry_acquire_value(event); }
is_direction(int0_status, int2_status, BMI160_INT_STATUS_2_ANYM_SIGN, BMI160_INT_STATUS_2_ANYM_FIRST_X, &direction); BMI160_DBG("Anymotion on axis %"PRIu8" in direction %"PRId32, axis, direction); accel_cb_sh...
(BMI160_Accel_Mode_Normal)
; } // get the FIFO length uint64_t last_frame_time = 0; uint16_t len = prv_get_current_fifo_length_and_timestamp(&last_frame_time); BMI160_DBG("Reading %d bytes", len); uint8_t fifo_frame_len = prv_get_fifo_frame_size(); bmi160_begin_burst(BMI160_REG_FIFO_DATA | BMI160_READ_FLAG); uint8_t curr_num_...
ell_bottom_y >= it->content_top_y && it->it.cell_bottom_y <= it->content_bottom_y); if (is_header_in_frame) { // Draw section header: prv_menu_layer_draw_section_header(it->it.menu_layer, &it->cell_layer, &it->it.cursor, it->ctx); // Draw the separator on top of the cell: if (top_diff >= it->it.cursor...
if (it->cursor.index.section >= num_sections) { break; // Reached last section } it->cursor.index.row = 0; it->cursor.h = prv_menu_layer_get_header_height(it->menu_layer, it->cursor.index.section); it->cell_bottom_y = it->cursor.y + it->cursor.h; // SECTION if (it->cursor.h > 0)...
_shake_detection(void) { bma255_write_register(BMA255Register_INT_EN_0, BMA255_INT_EN_0_SLOPE_X_EN | BMA255_INT_EN_0_SLOPE_Y_EN | BMA255_INT_EN_0_SLOPE_Z_EN); bma255_write_register(BMA255Register_INT_MAP_0, BMA255_INT...
(axis, &new_negative)
; negative = prv_raw_to_mgs(negative); prv_soft_reset(); int delta = positive - negative; delta = abs(delta); PBL_LOG(LOG_LEVEL_DEBUG, "Self test axis %c: %d Pos: %d Neg: %d Delta: %d (required %d)", AXIS_NAMES[axis], before, positive, negative, delta, SELFTEST_THRESHOLDS[axis...
_layer = &data->action_bar_layer; action_bar_layer_init(action_bar_layer); action_bar_layer_add_to_window(action_bar_layer, window); data->approve_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_CHECK); data->decline_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ACTION_BAR_ICON_X); actio...
{ BTPairingUIData *data = s_data_ptr; Window *window = &data->window; window_init(window, WINDOW_NAME("Bluetooth SSP")); window_set_window_handlers(window, &(WindowHandlers) { .load = prv_window_load, .unload = prv_window_unload, }); window_set_user_data(window, data); window_set_overrides_back_bu...
static void prv_pop_click_handler(ClickRecognizerRef recognizer, void *ctx) { prv_pop_window(); } static void prv_success_or_failure_click_config_provider(void *unused) { window_single_click_subscribe(BUTTON_ID_BACK, prv_pop_click_handler); window_single_click_subscribe(BUTTON_ID_UP, prv_pop_click_handler); ...
ession_ref = sys_hrm_manager_app_subscribe(1, 1, SECONDS_PER_MINUTE, HRMFeature_BPM); fake_system_task_callbacks_invoke_pending(); cl_assert_equal_b(hrm_is_enabled(HRM), false); // 3. Enabling with a subscriber should turn HRM on hrm_manager_enable(tr...
fake_system_task_callbacks_invoke_pending()
; cl_assert_equal_b(hrm_is_enabled(HRM), false); } void test_hrm_manager__can_turn_sensor_on(void) { fake_event_set_callback(prv_charger_event_cb); cl_assert(prv_can_turn_sensor_on()); // Add a subscription so we have a reason to turn the sensor on (if the conditions are right) sys_hrm_manager_app_subscrib...
/* * 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 (AMSCharacteristic c = 0; c < NumAMSCharacteristic; ++c) { cl_assert_equal_b(ams_can_handle_characteristic(s_characteristics[instance_idx][c]), expect_can_handle); }
810, 473, -113}, { -851, 386, -78}, { -886, 362, -59}, { -796, 392, -45}, { -744, 396, -58}, { -750, 414, -62}, { -779, 421, -56}, { -811, 410, -65}, { -856, 427, -90}, { -905, 457, -110}, { -955, 463, -115}, { -914, 431, -86}, { -1064, 447, -36}, { -1068, 509, -51}, ...
activity_test_feed_samples(data, chunk_size)
; rtc_set_time(rtc_get_time() + 1); samples_remaining -= chunk_size; if (minute_idx != samples_remaining / (60 * SAMPLES_PER_SECOND)) { activity_test_run_minute_callback(); minute_idx = samples_remaining / (60 * SAMPLES_PER_SECOND); prv_clear_event_queue(); } } } // ---------------...
ck[1]); cl_assert_equal_p(aaa, stack[2]); cl_assert_equal_p(aaaa, stack[3]); // go back two levels and then to sibling actual = __layer_tree_traverse_next__test_accessor(stack, ARRAY_LENGTH(stack), &current_stack, true); cl_assert_equal_p(ab, actual); cl_assert_equal_i(1, current_stack); cl_assert_equal_...
(layer_find_layer_containing_point(&parent, &GPoint(1, 1)), &child_f)
; // child layers are subject to their parents' bounds as well as their own (parent layers clip the // bounds of child layers) cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(15, 15)), &parent); cl_assert_equal_p(layer_find_layer_containing_point(&parent, &GPoint(-5, -5)), NULL); cl_asse...
reak; case JERRY_ERROR_TYPE: error_ref = JERRY_ERROR(TypeError, message_p, message_size); break; case JERRY_ERROR_URI: error_ref = JERRY_ERROR(URIError, message_p, message_size); break; default: EM_ASM_INT({ abort('Cannot create error type: ' + $0); }, error_t...
jerry_value_is_object(obj_val)
) { return TYPE_ERROR; } return (jerry_value_t)EM_ASM_INT({ var obj = __jerryRefs.get($0); return __jerryRefs.ref(obj[$1]); }, obj_val, index); } jerry_value_t jerry_set_property(const jerry_value_t obj_val, const jerry_value_t prop_name_val, ...
stance; } void shell_prefs_set_units_distance(UnitsDistance new_unit) { uint8_t uint_new_unit = new_unit; prv_pref_set(PREF_KEY_UNITS_DISTANCE, &uint_new_unit, sizeof(uint_new_unit)); } void shell_prefs_set_clock_24h_style(bool is24h) { prv_pref_set(PREF_KEY_CLOCK_24H, &is24h, sizeof(is24h)); } bool shell_pref...
app_install_get_id_for_uuid(uuid)
; } void quick_launch_set_app(ButtonId button, AppInstallId app_id) { QuickLaunchPreference pref = (QuickLaunchPreference) { .enabled = true, }; app_install_get_uuid_for_install_id(app_id, &pref.uuid); const char *key = NULL; switch (button) { case BUTTON_ID_UP: key = PREF_KEY_QUICK_LAUNCH_UP;...
{ return NULL; }
return kino_reel_gbitmap_create(bitmap, true); }
} // Teardown void test_graphics_draw_text_${BIT_DEPTH_NAME}__cleanup(void) { free(fb); } /////////////////////////////////////////////////////////// // Tests static FontInfo s_font_info; static const char *s_text_buffer = "Text Clipping"; static void prv_setup_resources(void) { // Setup resources fake_spi_fl...
GRect(4, -46, 72, 50)
, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); } void draw_text_single_line_wordwrap_clip_across_y(Layer* me, GContext* ctx) { graphics_context_set_text_color(ctx, GColorBlack); graphics_draw_text(ctx, s_text_buffer, &s_font_info, GRect(4, 20, 72, 32), GTextOver...
; char *values[] = { "val1", "val2", "val3", "val4", "val5" }; int value_len = strlen(values[0]); // insert all keys for (int i = 0; i < ARRAY_LENGTH(keys); ++i) { blob_db_insert(BlobDBIdTest, (uint8_t *)keys[i], key_len, (uint8_t *)values[i], value_len); } // check the dirty list blob_db_get_dirty_...
prv_generate_responses_from_phone()
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(LOG_LEVEL_DEBUG, "Disabling debugger now to save power...")
; hw_cpm_disable_debugger(); OS_TIMER_DELETE(s_dbg_disable_timer, OS_QUEUE_FOREVER); s_dbg_disable_timer = NULL; } static void prv_disable_debugger_with_delay(void) { s_dbg_disable_timer = OS_TIMER_CREATE("dbg", OS_MS_2_TICKS(DISABLE_DEBUG_DELAY_MS), false /* repeat */, ...
NYI", (int)compositing_mode); return; } } } } void bitblt_bitmap_into_bitmap_tiled_8bit_to_8bit(GBitmap *dest_bitmap, const GBitmap *src_bitmap, GRect dest_rect, ...
(&dest_rect)
, dest_row_info.max_x + 1); if (dest_end_x < dest_begin_x) { continue; } const GBitmapDataRowInfo src_row_info = gbitmap_get_data_row_info(src_bitmap, src_y); const uint8_t *src = src_row_info.data; // This is the initial position that takes into account destination de...
/* * 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...
(length <= pulse_link_max_send_size() - sizeof(PushPacket), "Packet to big to send")
; // We're blindly assuming that buf is the same pointer returned by // pulse_push_send_begin. If it isn't, we'll either crash here // when trying to dereference it or we'll hit the assert in // pulse_link_send. PushPacket *packet = (void *)((char *)buf - offsetof(PushPacket, ...
PB1Periph_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_p...
new_timer_service_init()
; regular_timer_init(); clock_init(); task_watchdog_init(); analytics_init(); register_system_timers(); system_task_timer_init(); init_drivers(); #if defined(IS_BIGBOARD) // Program a random S/N into the Bigboard in case it's not been done yet: mfg_write_bigboard_serial_number(); #endif #if defined...
gth); } static void prv_endpoint_handler_b( CommSession *session, const uint8_t *data, size_t length) { s_handler_call_count[HandlerB]++; prv_assert_data_matches_expected(data, length); } static void prv_endpoint_handler_c( CommSession *session, const uint8_t *data, size_t length) { s_handler_call_count...
{ const int batch_num = 10; char data = 'a'; for (int i = 0; i < batch_num; i++) { Receiver *receiver = g_default_kernel_receiver_implementation.prepare( FAKE_COMM_SESSION, &s_endpoints[0], 1); cl_assert(receiver != NULL); g_default_kernel_receiver_implementation.write( receiver, (uin...
//! Make sure that if cleanup runs and we are partially through updating a //! buffer the callback does not get called void test_default_kernel_receiver__receiver_cleanup(void) { char *data = "cleanup test!"; Receiver *receiver = g_default_kernel_receiver_implementation.prepare( FAKE_COMM_SESSION, &s_endpo...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
app_expandable_dialog_push(expandable_dialog)
; return expandable_dialog; }
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(&app_uuid, pc, lr, build_id, false /* is_rocky_app */)
; expected_blob.event = AnalyticsEvent_AppCrash; cl_assert_equal_last_blob(expected_blob); // Rocky.js app: expected_blob.event = AnalyticsEvent_RockyAppCrash; analytics_event_app_crash(&app_uuid, pc, lr, build_id, true /* is_rocky_app */); cl_assert_equal_last_blob(expected_blob); }
/* * 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_mock_type(bool)
; } bool bt_persistent_storage_has_pinned_ble_pairings(void) { return cl_mock_type(bool); } #define TEST_PINNED_ADDR_1 ((BTDeviceAddress){ .octets = { 0x11, 0x22, 0x33, 0x33, 0x44, 0x55 } }) #define TEST_PINNED_ADDR_2 ((BTDeviceAddress){ .octets = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff } }) bool bt_driver_id_generat...
NUTES_PER_DAY, .type = TimelineItemTypePin, .all_day = 1, .layout = LayoutIdTest, }, .attr_list = { .num_attributes = 0, .attributes = NULL, }, .action_group = { .num_actions = 0, .actions = NULL, }, .allocated_buffer = NULL, }, { .he...
iter_next(&iterator)
); cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id)); // check rollover behaviour cl_assert(!iter_next(&iterator)); cl_assert(uuid_equal(&state.pin.header.id, &s_items[3].header.id)); cl_assert(state.node); cl_assert(iter_prev(&iterator)); cl_assert(uuid_equal(&state.pin.header.id, &s_i...
nt16_t) ((bounds - 1) - value); const int16_t delta = ABS(delta_0) < ABS(delta_b) ? delta_0 : delta_b; return (int16_t) (value + delta * normalized / ANIMATION_NORMALIZED_MAX); } GPoint gpoint_attract_to_square(GPoint point, GSize size, int32_t normalized) { // hacky to square - TODO: implement for real point...
(a->y - ctx->origin.y, a->x - ctx->origin.x)
+ ctx->angle), TRIG_MAX_ANGLE) - TRIG_MAX_ANGLE / 2); const int16_t angle_b = ABS(positive_modulo( (atan2_lookup(b->y - ctx->origin.y, b->x - ctx->origin.x) + ctx->angle), TRIG_MAX_ANGLE) - TRIG_MAX_ANGLE / 2); return (angle_a > angle_b ? 1 : -1); } GPointIndexLookup *gdraw_command_list_create_i...
positorTransitionDirectionRight, GColorWhite); } void test_graphics_window_stack_animation__right_flip_first_frame_clipping(void) { prv_test_clipping_mask(prv_right_flip_first_frame_clipping, "right_flip_first_frame_clipping"); }; // This test records a clip...
{ GColor8 color = GColorFromRGB(1 * x * UINT8_MAX / DISP_COLS, 2 * x * UINT8_MAX / DISP_COLS, 4 * x * UINT8_MAX / DISP_COLS); if (row_info.min_x <= x && x <= row_info.max_x) { row_info.data[x] = color.argb; } }
qual_i(event.health_event.type, HealthEventSleepUpdate); // ----------------------------------- // Test that we receive history update events fake_event_reset_count(); fake_event_set_callback(prv_fake_history_event_cb); s_captured_history_event = (PebbleEvent) { }; s_num_captured_history_events = 0; // ...
(value, 2 * SECONDS_PER_HOUR /* 2am */)
; activity_get_metric(ActivityMetricSleepTotalSeconds, 1, &value); cl_assert_equal_i(value, 330 * SECONDS_PER_MINUTE); activity_get_metric(ActivityMetricSleepExitAtSeconds, 1, &value); cl_assert_equal_i(value, 7 * SECONDS_PER_HOUR + 45 * SECONDS_PER_MINUTE /* 7:45am */); // Assert that we got the same slee...
f(local_status_out) - sizeof(local_status_out.crc); local_status_out.crc = crc32(CRC32_INIT, &local_status_out, crc_len); // Full duplex transaction to exchange Status: { spi_transfer_data transfer = { .wbuf = &local_status_out, .rbuf = &remote_status_in, .length = sizeof(SPITransportMsgSta...
(&s_tx_buffer)
; bool should_continue = (has_more_tx_data || should_continue_to_rx_data); s_is_transacting = should_continue; prv_unlock(); return should_continue; } static void prv_host_transport_main(void *ctx) { static int8_t s_ble_host_transport_wdog_id; s_ble_host_transport_wdog_id = sys_watchdog_register(false); ...
anceMeters, Thursday, 66); activity_metrics_prv_set_metric(ActivityMetricDistanceMeters, Wednesday, 22); activity_get_metric(ActivityMetricDistanceMeters, 2, metric_values); cl_assert_equal_i(metric_values[0], 66); cl_assert_equal_i(metric_values[1], 22); cl_assert_equal_i(activity_metrics_prv_get_distance_mm...
(0, health_service_peek_current_activities())
; } // --------------------------------------------------------------------------------------- // Test that we report the that a Sleep session is ongoing. void test_activity__activity_sessions_sleep_ongoing_then_delete(void) { // Start activity tracking. This method assumes it can be called from any task, so we must...
gmtoff = 4200; tmbuf[0] = '\0'; strftime(tmbuf, sizeof(tmbuf), "%z", &jan_2_2015__13_00_00); cl_assert_equal_s(tmbuf, "+0110"); jan_2_2015__13_00_00.tm_gmtoff = 36000; tmbuf[0] = '\0'; strftime(tmbuf, sizeof(tmbuf), "%z", &jan_2_2015__13_00_00); cl_assert_equal_s(tmbuf, "+1000"); jan_2_2015__13_00_00....
(tmbuf, sizeof(tmbuf), "%02R %06t %04T", &jan_2_10015__13_00_00)
; cl_assert_equal_s(tmbuf, "13:00 \t 13:00:00"); tmbuf[0] = '\0'; strftime(tmbuf, sizeof(tmbuf), "%5u %3V", &jan_2_10015__13_00_00); cl_assert_equal_s(tmbuf, "00005 001"); tmbuf[0] = '\0'; strftime(tmbuf, sizeof(tmbuf), "%9z", &jan_2_10015__13_00_00); cl_assert_equal_s(tmbuf, "+0000"); #endif tmbuf[0...
TATIC, 10); cl_assert(fd >= 0); cl_assert(pfs_close(fd) == S_SUCCESS); } cl_assert(pfs_active_in_region(0, pfs_get_size())); // delete every page and make sure pfs is active for (int i = 0; i < num_pages(); i++) { snprintf(file_name, sizeof(file_name), "file%d", i); cl_assert(pfs_remove(file_n...
snprintf(buf, sizeof(buf), "This is small buf %d!", i)
; int len = strlen(buf); char rbuf[len]; int fd = pfs_open(file_small, OP_FLAG_READ, FILE_TYPE_STATIC, 0); cl_assert(fd >= 0); cl_assert_equal_i(pfs_read(fd, (uint8_t *)rbuf, len), len); cl_assert(memcmp(rbuf, buf, len) == 0); cl_assert(fd >= 0); cl_assert(pfs_close(fd) == S_SUCCESS); ...
_millivolts(high_mv); periodic_timer_trigger(20); cl_assert_equal_i(battery_get_charge_state().charge_percent, 50); PBL_LOG(LOG_LEVEL_DEBUG, "▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲"); // Should still update if it goes lower fake_battery_set_millivolts(lower_mv); periodic_timer_trigger(20); cl_assert_equal_i(battery_ge...
cl_assert(result.charge_percent <= last_discharge_percent); cl_assert(!result.is_charging); cl_assert(!result.is_plugged); last_discharge_percent = result.charge_percent; } }
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(app_sdk_version, old_style_double_free_handling_version)
n /* sn */, s_short_data_fragment, sizeof(s_short_data_fragment) - sn); } void test_ppogatt__retransmit_max_number_of_times(void) { test_ppogatt__open_session_when_found_pebble_app(); Transport *transport = ppogatt_client_for_uuid(&s_meta_v0_system.app_uuid); // Get a packet in flight: ...
(s_characteristics[0][PPoGATTCharacteristicMeta], (const uint8_t *) &s_meta_v0_system, sizeof(s_meta_v0_system), BLEGATTErrorSuccess)
; // Expect subscribe request was made: fake_gatt_client_subscriptions_assert_subscribe(s_characteristics[0][PPoGATTCharacteristicData], BLESubscriptionNotifications, GAPLEClientKernel); // During service re-disco...
nse); size_t message_length = sizeof(HcProtocolMessage) + response_payload_length; HcProtocolMessage *response = kernel_malloc_check(message_length); response->message_length = message_length; response->endpoint_id = to_request->endpoint_id; response->command_id = to_request->command_id; response->transacti...
mutex_create_recursive()
; } //! Should be called when stack is brought up. void hc_protocol_init(void) { s_outstanding_enqueues = 0; s_hc_next_transaction_id = 0; s_retry_semph = xSemaphoreCreateBinary(); prv_update_hc_state(HcProtoclStateIsInitialized); } //! Should be called when stack is torn down. void hc_protocol_deinit(void) {...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
while (s1[len]) { p = s2; while (*p) { if (s1[len] == *p) { break; } p++; } if (!*p) { return len; } len++; }
return len; }
k_call(s_graphics_context_set_stroke_color) { .ctx = ctx, .color = color, }; } void graphics_context_set_stroke_width(GContext* ctx, uint8_t stroke_width) {} void graphics_draw_line(GContext* ctx, GPoint p0, GPoint p1) {} void graphics_fill_rect(GContext *ctx, const GRect *rect) {} void graphics_fill_round_re...
cl_assert_parsed_color("#0000FF", &GColorBlue)
4 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 writing, software...
string_list_get_at(list, 0)
); cl_assert_equal_s("bc", string_list_get_at(list, 1)); // add a string to an empty string list list->serialized_byte_length = 0; string_list_add_string(list, 20, "hello", 10); cl_assert_equal_i(5, list->serialized_byte_length); cl_assert_equal_i(1, string_list_count(list)); cl_assert_equal_s("hello", s...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(RTC_TICKS_HZ < (1000000 / 450), "Tick period < 450µs")
; void bma255_gpio_init(void) { periph_config_acquire_lock(); gpio_af_init(&BMA255_SCLK_CONFIG, GPIO_OType_PP, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL); gpio_af_init(&BMA255_MISO_CONFIG, GPIO_OType_PP, GPIO_Speed_50MHz, GPIO_PuPd_NOPULL); gpio_af_init(&BMA255_MOSI_CONFIG, GPIO_OType_PP, GPIO_Speed_50MHz, GPIO_PuPd...
window to the window stack, its load handler is // called, it calls to set the click config, and the click config is set properly. void test_window_stack__window_flow(void) { Window *window = window_create(); window_set_window_handlers(window, &(WindowHandlers){ .load = prv_window_load, .unload = prv_windo...
{ Window *window = window_create(); window_set_window_handlers(window, &(WindowHandlers){ .load = prv_pop_window_load, .unload = prv_window_unload }); WindowStack *stack = app_state_get_window_stack(); // Switch to the app state to push a window stub_pebble_tasks_set_current(PebbleTask_App); cl...
// Description: // In this test, we push a window during the unload handler of a window. void test_window_stack__push_during_window_unload(void) { Window *window = window_create(); window_set_window_handlers(window, &(WindowHandlers){ .load = prv_window_load, .unload = prv_push_window_unload }); Win...
ation->values.from.grect.origin.x, property_animation->values.to.grect.origin.x); result.origin.y = distance_interpolate( distance_normalized, property_animation->values.from.grect.origin.y, property_animation->values.to.grect.origin.y); result.size.w = distance_interpolate( distance_n...
{ if (property_animation == NULL) { return; } animation_legacy2_unschedule(&property_animation->animation); task_free(property_animation); }
void property_animation_legacy2_init_layer_frame( PropertyAnimationLegacy2 *property_animation, struct Layer *layer, GRect *from_frame, GRect *to_frame) { static const PropertyAnimationLegacy2Implementation implementation = { .base = { .update = (AnimationLegacy2UpdateImplementation) property_anim...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
strtol("573888", NULL, 10)
, 573888); cl_assert_equal_i(strtol("713713", NULL, 10), 713713); cl_assert_equal_i(strtol("2147483646", NULL, 10), 2147483646); cl_assert_equal_i(strtol("-2147483647", NULL, 10), -2147483647); } void test_strtol__whitespace_pfx(void) { cl_assert_equal_i(strtol(" 500", NULL, 10), 500); cl_assert_equal_i...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ if (timeout-- == 0) { PBL_LOG(LOG_LEVEL_ERROR, "Display busy-wait timeout expired!"); return false; } delay_us(100); }
return true; } static void prv_screen_on(void) { prv_start_command(CMD_DISPLAY_ON); prv_end_command(); } static void prv_screen_off(void) { prv_start_command(CMD_DISPLAY_OFF); prv_end_command(); } void prv_draw_scene(uint8_t scene) { prv_start_command(CMD_DRAW_SCENE); prv_send_command_arg(scene); pr...
ion"); return; } comm_session_send_data(session, MUSIC_CTRL_ENDPOINT, (const uint8_t *)&cmd, 1, COMM_SESSION_DEFAULT_TIMEOUT); } static const uint8_t* prv_read_ptr_and_length_from_buffer(const uint8_t *iter, const uint8_t *iter_...
music_update_player_volume_percent((uint8_t)*msg)
-------------------------- // Sample captured: 2015-10-05 15:54:31 local AccelRawData *activity_sample_walk_200_pbl_25661_7(int *len) { // The unit tests parse the //> TEST_.* lines below for test values //> TEST_NAME walk_200_pbl_25661_7 //> TEST_EXPECTED 200 //> TEST_EXPECTED_MIN 165 //> TEST_EXPECTED_MAX 2...
{ 792, 536, -104}, { 688, 512, -208}, { 624, 264, -280}, // 5 seconds { 656, 184, -288}, { 752, 56, -352}, { 920, 152, -440}, { 984, 184, -432}, { 1144, 288, -408}, { 1256, 336, -296}, { 1520, 464, -296}, { 1280, 576, -416}, { 960, 616, -440}, { 944, 592, -368}, ...
{ 1520, 528, -440}, { 1168, 696, -704}, { 1024, 624, -768}, { 1288, 448, -560}, { 1224, 272, -296}, { 872, 320, -240}, { 616, 352, -136}, { 472, 336, -16}, { 544, 440, -168}, { 520, 448, -224}, { 592, 472, -384}, { 712, 528, -432}, // 8 seconds { 912, 536, -496},...
{ 1504, 104, 208}, { 1760, 496, 56}, { 952, 464, 0}, { 880, 280, 48}, { 1064, 104, 200}, { 1112, 56, 208}, { 912, 64, 168}, { 848, 64, 128}, { 800, 136, 48}, { 784, 48, 104}, { 752, -24, 128}, { 856, -80, 144}, { 968, -72, 24}, { 1048, 56, -32}, { 1680, -112, ...
{ 848, 168, 104}, // 84 seconds { 672, 248, 144}, { 648, 296, 136}, { 736, 336, 144}, { 776, 384, 96}, { 768, 480, -72}, { 824, 392, -80}, { 1080, 216, -64}, { 1240, 136, 40}, { 1720, 248, 32}, { 1424, 488, -32}, { 952, 464, -48}, { 1176, 304, 56}, { 1232, 15...
================== void repeating_timer_menu_cb(int index, void *ctx) { uint32_t expire_ms; int timer_idx_0 = 0; bool scheduled = false; menu_callback_prefix(index, ctx); // Repeating timer s_app_data->timer[timer_idx_0] = new_timer_create(); bool success = new_timer_start(s_app_data->timer[timer_idx...
app_timer_register(100 /*ms*/, timer_callback, cb_data)
; PBL_ASSERTN(s_app_data->app_timer); } // ================================================================================= void stuck_callback_menu_cb(int index, void *ctx) { void *cb_data = 0; uint32_t zero_flags = 0; menu_callback_prefix(index, ctx); // stuck callback s_app_data->timer[0] = new_timer...
so we have to jump through hoops to read kernel memory. TimerID timer_id = (TimerID) data; EventedTimerCallback timer_cb; void* timer_cb_data; // Get the user supplied callback pointer and data, remove the timer from our list, and delete it. sys_evented_timer_consume(timer_id, &timer_cb, &timer_cb_data); ...
PBL_ASSERTN(new_timer->sys_timer_id != TIMER_INVALID_ID)
; s_timer_list_head = list_prepend(s_timer_list_head, &new_timer->list_node); uint32_t flags = repeating ? TIMER_START_FLAG_REPEATING : 0; bool success = new_timer_start(new_timer->sys_timer_id, timeout_ms, prv_sys_timer_callback, (void*)(intptr_t)new_timer->sys_timer_id, flags)...
"../graphics/util.h" // Fakes ///////////////////// #include "fake_graphics_context.h" #include "fake_spi_flash.h" #include "../../fixtures/load_test_resources.h" static GContext s_ctx; void clock_get_time_tm(struct tm* time_tm) { rtc_get_time_tm(time_tm); } static FrameBuffer *fb = NULL; static GBitmap *s_dest...
(content_size)
); callback(ctx, content_size); } } void time_selection_window_set_to_current_time(TimeSelectionWindowData *date_time_window); void time_selection_window_configure(TimeSelectionWindowData *time_selection_window, const TimeSelectionWindowConfig *config); void time_selection_...
activity_get_metric_values.out.history[0] = 123; s_sys_activity_get_metric_values.out.history[1] = 456; HealthValue result = health_service_sum_today(HealthMetricStepCount); cl_assert_equal_i(123, result); cl_assert_equal_i(s_sys_activity_get_metric_values.in.metric, ActivityMetricStepCount); cl_assert_equal_...
cl_assert_equal_b(result, false)
; // too far in the past result = prv_calculate_time_range( now - (ACTIVITY_HISTORY_DAYS + 10) * SECONDS_PER_DAY, now - (ACTIVITY_HISTORY_DAYS + 2) * SECONDS_PER_DAY, NULL); cl_assert_equal_b(result, false); // start after end result = prv_calculate_time_range(now - 100, now - 200, NULL); cl_asse...
== 1) { prv_fill_horizontal_line(ctx, GPoint(x0 - radius, y0), radius + 1); } prv_fill_horizontal_line(ctx, GPoint(x0 - x, y0 + y), x + 1); prv_fill_horizontal_line(ctx, GPoint(x0 - y, y0 + x), y + 1); } if (quadrant & GCornerBottomRight) { if (x == 1) { prv_fill_horizo...
if (starting_edge > ending_edge || (ignore_close_angles && starting_edge == ending_edge)) { // Two separate drawings... starting_edge = MAX(starting_edge, left); ending_edge = MIN(ending_edge, right); if (left <= ending_edge) { graphics_private_draw_horizontal_line(ctx, y, ...
} static GCornerMask prv_get_full_quadrants(int8_t starting_quadrant, int8_t ending_quadrant) { GCornerMask quadrants_solid = GCornerNone; if (starting_quadrant >= ending_quadrant) { ending_quadrant += QUADRANTS_NUM; } for (int i = starting_quadrant + 1; i < ending_quadrant; i++) { quadrants_solid =...
, &light); } else if (state->test_entry.version == 3) { sscanf(token + strlen(token) + 1, "%d, 0x%x, %d, %d, %d", &steps, &orientation, &vmc, &light, &plugged_in); } else { cl_assert(false); } fflush(stdout); PBL_ASSERTN(state->test_entry.num_samples < SLEEP...
{ sscanf(token + strlen(token) + 1, "%f", &state->test_entry.weight); }
else if (strcmp(token, "TEST_NAME") == 0) { sscanf(token + strlen(token) + 1, "%s", state->test_entry.name); } } // If this is a "static AlgDlsMinuteData samples[] = {" line, skip it if (strcmp(token, "static") == 0) { continue; } // Grab a sample if (strcmp(token, "{") ==...
/* * 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...
(buf, "res_bank255")
; } void test_string__test_itoa_int(void) { char buf[32]; itoa_int(0, buf, 10); cl_assert(0 == strcmp(buf, "0")); itoa_int(-0, buf, 10); cl_assert(0 == strcmp(buf, "0")); itoa_int(1, buf, 10); cl_assert(0 == strcmp(buf, "1")); itoa_int(-1, buf, 10); cl_assert(0 == strcmp(buf, "-1")); itoa_int(...
LES]; ActivityFileTestEntry test_entry; } ActivitySampleDiscoveryState; static ActivitySampleDiscoveryState s_activity_sample_discovery_state; // --------------------------------------------------------------------------------------- static bool prv_parse_accel_samples_file(AccelSampleDiscoveryState *state) { //...
{ continue; }
row_info.min_x - dest_rect.origin.x, 0); const int16_t dest_begin_x = dest_delta_begin_x ? dest_row_info.min_x : dest_rect.origin.x; const int16_t dest_end_x = MIN(grect_get_max_x(&dest_rect), dest_row_info.max_x + 1); if (dest_end_x < dest_begin_x) { continue; } const int16_t corrected_src_x...
{ ++src_block; if (src_block == src_block_end) { // Wrap-around source bitmap horizontally: src_block = src_block_begin; src_start_idx = src_line_wrap_idx; src_end_idx = MIN(src_line_wrap_end_idx, src_start_idx + row_bits_left); } else { src_sta...
} } } void bitblt_bitmap_into_bitmap_tiled(GBitmap* dest_bitmap, const GBitmap* src_bitmap, GRect dest_rect, GPoint src_origin_offset, GCompOp compositing_mode, GColor tint_color) { if (bitblt_compositing_mode_is_noop(compositing_mode, ...
"There are 0x10 lights, 0xfffffffc"); // Zero padded minimum character output snprintf(dstbuf, 256, "There are %03x lights, %03x", 16, -4); cl_assert_equal_s(dstbuf, "There are 010 lights, fffffffc"); // Space padded minimum character output snprintf(dstbuf, 256, "There are %3x lights, %3x", 16, -4); cl_a...
(dstbuf, "zero1")
; // Minimum digits output (negative digits, acts as zero) snprintf(dstbuf, 256, "%.-3Xzero%.-3X", 0, 1); cl_assert_equal_s(dstbuf, "zero1"); // Minimum digits output (non-zero digits outputting zero) snprintf(dstbuf, 256, "%.1Xzero%.1X", 0, 1); cl_assert_equal_s(dstbuf, "0zero1"); // Variable length c...
op = workout_service_stop_workout, .update_data = workout_data_update, .metric_to_string = workout_data_fill_metric_value, .get_metric_value = workout_data_get_metric_value, .get_distance_string = health_util_get_distance_string, }; data->active_window = workout_active_create_for_activity_type(type...
(workout_dialog, i18n_get("Workout\nEnded", workout_dialog))
; workout_dialog_set_action_bar_hidden(workout_dialog, true); i18n_free_all(workout_dialog); app_workout_dialog_push(workout_dialog); } //////////////////////////////////////////////////////////////////////////////////////////////////// // Public Functions void workout_push_summary_window(void) { WorkoutApp...
client_reset_request); free(s_client_reset_complete); } void prv_notify_services_discovered(int num_services_to_register) { for (int i = 0; i < s_num_service_instances && i < num_services_to_register; i++) { ppogatt_handle_service_discovered(s_characteristics[i]); } } void test_ppogatt__find_pebble_app_and_...
(ppogatt_has_client_for_uuid(&future_meta_non_compatible.app_uuid), false)
; } void test_ppogatt__handles_invalid_uuid_meta(void) { PPoGATTMetaV0 meta_invalid_uuid = s_meta_v0_system; meta_invalid_uuid.app_uuid = UUID_INVALID; prv_notify_services_discovered(1); ppogatt_handle_read_or_notification(s_characteristics[0][PPoGATTCharacteristicMeta], ...
\n", pfs_get_size() - 1024); cl_assert(fd >= 0); cl_assert(pfs_close(fd) == S_SUCCESS); cl_assert(pfs_remove(name) == S_SUCCESS); } void test_pfs__active_regions(void) { pfs_format(false); cl_assert(!pfs_active_in_region(0, pfs_get_size())); // erase every page and make sure pfs is active pfs_format(tr...
{ // reset the flash fake_spi_flash_cleanup(); fake_spi_flash_init(0, 0x1000000); extern void ftl_force_version(int version_idx); pfs_init(true); ftl_force_version(1); // simulate a migration by leaving leaving files in various states // in the first region. Then try to add another region and confirm ...
cl_assert_equal_i(pfs_read(fd, (uint8_t *)rbuf, len), len); cl_assert(memcmp(rbuf, buf, len) == 0); cl_assert(fd >= 0); cl_assert(pfs_close(fd) == S_SUCCESS); } } static uint32_t s_watch_file_callback_called_count = 0; static void prv_file_changed_callback(void *data) { s_watch_file_callback_calle...
se_priority - 2, false); modal_manager_event_loop_upkeep(); cl_assert_equal_i(window1->on_screen, false); cl_assert_equal_i(window2->on_screen, true); window_stack_remove(window2, false); modal_manager_event_loop_upkeep(); cl_assert_equal_i(window2->on_screen, false); cl_assert_equal_i(window1->on_sc...
cl_assert_equal_i(window_stack_count(app_stack), 1)
cation_storage.h" #include "services/normal/notifications/notifications.h" #include "services/normal/timeline/timeline.h" #include "system/logging.h" #include "system/passert.h" #include "util/pstring.h" #include <stdio.h> static const Uuid uuid_reminders_data_source = UUID_REMINDERS_DATA_SOURCE; static void prv_dis...
reminder_db_insert_item(&reminder)
; timeline_item_free_allocated_buffer(&reminder); return true; } return false; } static bool prv_find_existing_notification(TimelineItem *notification, CommonTimelineItemHeader *existing_header_out) { // PBL-9509: iOS' Calendar app uses the timestamp of the ANCS...
/* * 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...
(fb, &(GSize) {DISP_COLS, DISP_ROWS})
; } // Teardown void test_graphics_stroke_circle_${BIT_DEPTH_NAME}__cleanup(void) { free(fb); } // Tests //////////////////////////////////// #define RADIUS_BIG 15 #define RADIUS_MEDIUM 8 #define RADIUS_MIN_CALCULATED 3 #define RADIUS_MAX_PRECOMPUTED 2 #define RADIUS_SMALL 1 #define RADIUS_NONE 0 #define STROKE_BI...
.node; s_data.max_used_size = TEST_TEXT_SIZE; GSize size; graphics_text_node_draw(&text_node.node, ctx, &TEST_TEXT_BOX, NULL, &size); cl_assert(size.w > 0); cl_assert(size.h > 0); cl_assert_equal_i(size.w, TEST_TEXT_SIZE.w); cl_assert_equal_i(size.h, TEST_TEXT_SIZE.h); } void test_graphics_text_node__te...
graphics_text_node_container_add_child(&horizontal_a->container, &text_b->node)
ual_i(position, (680 - 310)); // Run to the completion of B, start of C prv_advance_to_ms_with_timers(start_ms + 730 + 2 * MIN_FRAME_INTERVAL_MS); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 1); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, c), 1); cl_as...
prv_now_ms()
; const AnimationHandlers handlers = { .stopped = prv_stopped_unschedule_all_handler, }; void *context = NULL; Animation *a = prv_create_test_animation(); animation_set_duration(a, duration_a); animation_set_delay(a, delay_a); animation_set_handlers(a, handlers, context); animation_set_auto_destr...
/* * 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(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_assign-expect.8bit.pbi"))
; memset(dest_data, GColorGreen.argb, sizeof(dest_data)); bitblt_bitmap_into_bitmap(&dest_bitmap, src_bitmap, GPointZero, GCompOpClear, GColorWhite); cl_assert(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_assign-expect.8bit.pbi")); memset(dest_data, GColorGreen.argb, sizeof(dest_data)); // Update source ...
ssions and * limitations under the License. */ #include "animation_private_legacy2.h" #include "animation_legacy2.h" #include "applib/ui/animation_timing.h" #include "process_state/app_state/app_state.h" #include "kernel/kernel_applib_state.h" #include "kernel/pbl_malloc.h" #include "system/passert.h" #include "sys...
{ PBL_ASSERTN(animation != NULL); *animation = (AnimationLegacy2){}; animation->duration_ms = 250; animation->curve = AnimationCurveEaseInOut; animation->handlers = (AnimationLegacy2Handlers) { NULL, NULL }; animation->context = NULL; animation->is_completed = false; }
static int animation_legacy2_scheduler_comparator(AnimationLegacy2 *animation_legacy2_a, AnimationLegacy2 *animation_legacy2_b) { return serial_distance32(animation_legacy2_a->abs_start_time_ms, animation_legacy2_b->abs_start_time_ms); } ...
setup_test(&context, false, 5, GColorBlack, GColorBlack, false); graphics_fill_rect(&context, &GRect(10, 20, 40, 10)); ASSERT_CALLED(prv_fill_rect_non_aa(&context, &GRect(10, 20, 40, 10), 0, GCornerNone, GColorBlack)); setup_test(&context, false, 5, GColorBlack, GColorBlack, false); graphics_fill_circle(&cont...
graphics_draw_round_rect(&context, &GRect(20, 80, 40, 10), 4)
); setup_test(&context, true, 2, GColorBlack, GColorBlack, true); ASSERT_NO_CHANGE(graphics_draw_line(&context, GPoint(5, 5), GPoint(45, 10))); ASSERT_NO_CHANGE(graphics_draw_rect(&context, &GRect(10, 20, 40, 10))); ASSERT_NO_CHANGE(graphics_draw_circle(&context, GPoint(50, 50), 10)); ASSERT_NO_CHANGE(graphi...
008}, { 48, 0, -1000}, { 48, 8, -1000}, { 48, 0, -1000}, { 48, 8, -1000}, { 48, 8, -992}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 0, -1008}, { 48, 8, -1000}, { 48, 0, -1000}, { 48, 8, -992}, { 48, 0, -1000}, { 48, 0, -1000}, { 40, 8, -992}, { 48, 8, -1000}, ...
{ 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1008}, { 48, 8, -1000}, { 48, 0, -1008}, { 48, 8, -1000}, { 48, 0, -1008}, { 48, 0, -1000}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1008}, { 48, 8, -1000}, { 40, 8, -1000}, {...
{ 48, 0, -1000}, { 40, 0, -1008}, { 48, 0, -1000}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1008}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 8, -1000}, { 48, 0, -1000}, ...
0x69, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x20, 0x4d, 0x61, 0x72, 0x74, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf9, 0x92, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x75, 0x36, 0x9c, 0x6e, 0x1a, 0x1b, 0xeb, 0x5f, 0xfb, 0x89, 0xdb, 0x0b, 0xec, 0xa5, 0x95, 0x7a, 0x44, 0xf6, 0x1c, 0x47, 0x90, 0...
(data_len, data_size)
; cl_assert_equal_m(expected_raw_data, data, sizeof(expected_raw_data)); } void test_bluetooth_persistent_storage__v1_bt_classic(void) { #if UNITTEST_BT_PERSISTENT_STORAGE_VERSION != 1 // We only care about BT Classic in v1. return; #endif BTDeviceAddress address = { .octets = {0x5, 0x1b, 0x85, 0xe3, 0xb8...
_pages_and_wrap_around(void) { bool toggle = false; shared_prf_storage_wipe_all(); // Make sure to wrap around a few times and confirm that works for (uint32_t iter = 0; iter < 3; iter++) { toggle = false; // Iterate through all possible pages and keep writing new data, confirm it's the right data. ...
shared_prf_storage_get_valid_page_number()
, 0); SharedPRFData data; flash_read_bytes((uint8_t *)&data, SPRF_PAGE_FLASH_OFFSET(shared_prf_storage_get_valid_page_number()), sizeof(data)); cl_assert(data.getting_started.crc != 0xFFFFFFFF); uint32_t new_crc = 0; flash_write_bytes((uint8_t *)&new_crc, ...
se loading the bitmap may modify the // metadata! We will use `glyph_buffer` as the final data, and leave `data` as the uncooked // version, that way we can push `data` into the circular cache. memcpy(font_cache->glyph_buffer, data, sizeof(LineCacheData)); font_cache->glyph_buffer_key = cache_key; final_data...
(codepoint)
s_current_minute = 14; cron_service_wakeup(); cl_assert_equal_i(s_num_alarms_fired, 1); } //////////////////////////////////////////////////////////////////////////////////////////////////// //! Alarm Timeline Pin Tests void test_alarm__pin_add(void) { const AlarmId dummy_alarm_id = 0; const AlarmKind alarm_...
alarm_get_next_enabled_alarm(&next_alarm_time)
; cl_assert_equal_i(next_alarm_time, s_current_day + 10 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE); // First alarm goes off. Second one should be up s_current_hour = 10; s_current_minute = 30; cron_service_wakeup(); cl_assert_equal_i(s_num_alarms_fired, 1); cl_assert_equal_i(s_num_...
/* * 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...
{ kernel_le_client_deinit(); gap_le_connect_deinit(); gap_le_slave_discovery_deinit(); gap_le_advert_deinit(); gap_le_scan_deinit(); gap_le_connection_deinit(); }
bt_unlock(); }
/* * 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...
strcmp(buf, "2147483647")
); // min int32 itoa_int(-2147483647, buf, 10); cl_assert(0 == strcmp(buf, "-2147483647")); } void test_string__test_byte_stream_to_hex_string(void) { char result_buf[256]; // arbitraily large const uint8_t byte_stream[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; const char *expected_result_fwd = "0001020304050...
oc.h" #include "stubs_pebble_tasks.h" #include "stubs_resources.h" #include "stubs_ui_window.h" #include "stubs_unobstructed_area.h" void framebuffer_clear(FrameBuffer* f) {} void graphics_context_move_draw_box(GContext* ctx, GPoint offset) {} typedef uint16_t ResourceId; const uint8_t *resource_get_builtin_bytes(ResA...
kino_reel_create_with_resource(resource_id)
; cl_assert(kino_reel); cl_assert(kino_reel_get_type(kino_reel) == KinoReelTypePDCS); kino_reel_set_elapsed(kino_reel, 0); GDrawCommandList *list1 = kino_reel_get_gdraw_command_list(kino_reel); GDrawCommandList *list1_direct = gdraw_command_frame_get_command_list( gdraw_command_sequence_get_frame_by_el...
l_b(s_dls_private_handle_disconnect_called, true); cl_assert_equal_b(s_comm_session_event_put, true); } void test_session__get_type_app(void) { Transport *transport = (Transport *) TransportID1; CommSession *session = comm_session_open(transport, &s_transport_imp, Trans...
comm_session_deinit()
); comm_session_close(session, CommSessionCloseReason_UnderlyingDisconnection); } void test_session__send_next_deduping(void) { Transport *transport = (Transport *) TransportID1; CommSession *session = comm_session_open(transport, &s_transport_imp, TransportDestinationS...
{ connection = connection_by_idx(conn_idx); PBL_ASSERTN(connection); }
prv_unlock(); return connection; } static bool prv_connection_by_address_list_filter_cb(ListNode *found_node, void *data) { const BTDeviceInternal *desired_addr = (const BTDeviceInternal *)data; const Connection *connection = (const Connection *)found_node; return (bt_device_internal_equal(desired_addr, &co...
atchfacesData *data) { return app_menu_data_source_get_count(&data->data_source); } static void draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, SettingsWatchfacesData *data) { AppMenuNode *node = app_menu_data_source_get_node_at_index(&data->data_sourc...
WINDOW_NAME("Watchfaces")
); window_set_user_data(window, data); window_set_window_handlers(window, &(WindowHandlers) { .load = prv_window_load, .appear = prv_window_appear, .unload = prv_window_unload, }); const bool animated = true; app_window_stack_push(window, animated); } //////////////////// // App boilerplate stat...
s, 0, sizeof(state->hr.weights)); state->hr.metrics.previous_median_bpm = 0; state->hr.metrics.previous_median_total_weight_x100 = 0; } mutex_unlock_recursive(state->mutex); } // -------------------------------------------------------------------------------------------- void activity_metrics_prv_add_medi...
if (new_history.utc_sec == 0) { new_history.utc_sec = utc_now; }
// Init current value *m_info.value_p = new_history.values[0]; // Only write to flash if the values change or this is a new day (to update the timestamp) if (memcmp(old_history.values, new_history.values, sizeof(old_history.values)) != 0 || old_age != 0) { // Write out the u...
_get_selected_index(menu_layer); bool is_selected = menu_index_compare(&selected_index, cell_index) == 0; return is_selected ? MENU_CELL_ROUND_FOCUSED_TALL_CELL_HEIGHT : menu_cell_basic_cell_height(); } void test_menu_layer__default_ignores_row_height_for_selection(void) { MenuLayer l; const int height = 180; ...
(NORMAL - FOCUSED, scroll_layer_get_content_offset(&l.scroll_layer).y)
; cl_assert_equal_i(FOCUSED, l.selection.h); cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionUp]); cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionDown]); menu_layer_set_selected_next(&l, false, MenuRowAlignNone, false); cl_assert_equal_i(3 * NORMAL, l.selection.y); ...
e cl_assert_equal_i(kino_reel_get_elapsed(test_reel), 20); } void test_kino_player__infinite_animation_finite_reel_reverse(void) { // Choose duration and elapsed to have clean division for // ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number test_reel_data->duration_ms = 300; kino_player_play(tes...
kino_reel_get_elapsed(test_reel)
, ANIMATION_DURATION_INFINITE); } void test_kino_player__create_animation_is_immutable(void) { test_reel_data->duration_ms = 300; Animation *animation = (Animation *)kino_player_create_play_animation(test_player); cl_assert_equal_i(animation_is_scheduled(animation), false); cl_assert_equal_i(animation_is_immut...
rcle(ctx, GPoint(14, 28), 12); } void across_ny_layer_update_callback(Layer* me, GContext* ctx) { graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_antialiased(ctx, false); graphics_draw_circle(ctx, GPoint(14, -14), 12); } void test_graphics_draw_circle_${BIT_DEPTH_NAME}__origin_layer(vo...
(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, true, 1)
with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS); 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), 1); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 1); cl_assert_equ...
(start_ms + duration_total + 1 * MIN_FRAME_INTERVAL_MS)
; cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, NULL), 3); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, NULL), 3); // If we keep going, we should repeat the whole sequence another time prv_advance_to_ms_with_timers(start_ms + 2 * (duration_total + 4 * MIN_FRAME_...
/* * 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...
reset_due_to_software_failure()
; } //! Assert function called by the STM peripheral library's //! 'assert_param' method. See stm32f2xx_conf.h for more information. void assert_failed(uint8_t* file, uint32_t line) { register uintptr_t lr __asm("lr"); uintptr_t saved_lr = lr; handle_passert_failed((const char*) file, line, saved_lr, "STM32", "...
/* * 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; }
prv_rail_ctl(bus, false); // Drain through pull-ups OutputConfig out_scl = { .gpio = bus->scl_gpio.gpio, .gpio_pin = bus->scl_gpio.gpio_pin, .active_high = true }; gpio_output_init(&out_scl, GPIO_PuPd_NOPULL, GPIO_Speed_2MHz); gpio_output_set(&out_scl, false); OutputConfig out_sda = { ....
*action_bar_layer_legacy2_create(void) { ActionBarLayerLegacy2 * layer = task_malloc(sizeof(ActionBarLayerLegacy2)); if (layer) { action_bar_layer_legacy2_init(layer); } return layer; } void action_bar_layer_legacy2_deinit(ActionBarLayerLegacy2 *action_bar_layer) { layer_deinit(&action_bar_layer->layer);...
action_bar_layer_legacy2_set_icon(action_bar, button_id, NULL)
; } void action_bar_layer_legacy2_add_to_window(ActionBarLayerLegacy2 *action_bar, struct Window *window) { const uint8_t vertical_margin = 3; const GRect *window_bounds = &window->layer.bounds; GRect rect = GRect(0, 0, ACTION_BAR_LEGACY2_WIDTH, wi...
#include "services/common/comm_session/default_kernel_sender.h" #include "services/common/comm_session/session_send_buffer.h" #include "services/common/comm_session/session_transport.h" #include "services/common/comm_session/session_internal.h" #include "services/common/comm_session/session_send_queue.h" #include "serv...
comm_session_send_buffer_begin_write(&s_session, ENDPOINT_ID, max_length /* required_free_length */, TIMEOUT_MS)
; cl_assert(write_sb); uint8_t fake_data[max_length]; memset(fake_data, 0, max_length); comm_session_send_buffer_write(write_sb, fake_data, max_length); comm_session_send_buffer_end_write(write_sb); // Set a yield callback that gives the semph in time but does not clear out the send buffer: SemaphoreHand...
rue); prv_filled_update_proc(NULL, &ctx); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled_bottom_clipped_aa.${BIT_DEPTH_NAME}.pbi")); prv_reset(); test_graphics_context_init(&ctx, fb); s_current_path = s_house_path; ctx.draw_state.clip_box = GRect(0, 0, SCREEN_WIDTH / 2, SCREEN_HEIGHT); g...
(&ctx.dest_bitmap, "gpath_filled_house_20_aa.8bit.pbi")
); // This case demonstrates tipping point that is also the starting point of the path prv_reset(); s_current_path = s_house_path; gpath_move_to(s_house_path, GPoint(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)); s_path_angle = 105; test_graphics_context_init(&ctx, fb); graphics_context_set_antialiased(&ctx, tru...
(void) { // Choose duration and elapsed to have clean division for // ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number test_reel_data->duration_ms = 300; kino_player_play(test_player); animation_set_reverse(test_player->animation, true); animation_set_elapsed(test_player->animation, 1234); // ...
animation_set_duration(test_player->animation, ANIMATION_DURATION_INFINITE)
; prv_play_animation_update(test_player->animation, 0); // intentionally bad value cl_assert_equal_i(kino_reel_get_elapsed(test_reel), 20); } void test_kino_player__create_infinite_animation_infinite_reel_forward(void) { // Choose duration and elapsed to have clean division for // ANIMATION_NORMALIZED_MAX * ...
/* * 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...
setup_pbi_test(TEST_PBI_FILE)
; cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE)); } // Tests 2-bit transparent palettized PBI loading into gbitmap // Result: // - gbitmap matches platform loaded PBI void test_pbi__color_2_bit_transparent(void) { GBitmap *bitmap = setup_pbi_test(TEST_PBI_FILE); cl_assert(gbitmap_pbi_eq(bitmap, TEST_PBI_FILE...
ler_calls, b), 0); // A should start out low distance = prv_last_update_distance(a); cl_assert(distance < TEST_ANIMATION_NORMALIZED_LOW); // Execute to the start of B prv_advance_to_ms_with_timers(start_ms + duration_a + 2 * MIN_FRAME_INTERVAL_MS); cl_assert_equal_i(prv_count_handler_entries(&s_started_h...
(&s_started_handler_calls, NULL)
data->config.context); } } static void prv_invoke_did_close(ActionMenu *action_menu) { ActionMenuData *data = window_get_user_data(&action_menu->window); if (data->config.did_close) { data->config.did_close(action_menu, data->performed_item, data->con...
(content_in, crumbs_anim, NULL)
; return spawn_anim; #else return content_in; #endif } static Animation* prv_create_content_out_animation(ActionMenuData *data, const ActionMenuLevel *level) { // animate the ease out of the current level GRect *start = &data->action_menu_layer.layer.frame; GRect stop = *start; stop.origin.x = crumbs_l...
prv_exit_and_send_result_event(data, data->error_exit_status); } } static void prv_error_dialog_unload(void *context) { VoiceUiData *data = context; prv_handle_error_retries(data); } static void prv_init_dialog(VoiceUiData *data, Dialog *dialog, const char *text, uint32_t resource_id, bool has_timeout, G...
bt_conn_dialog_init(bt_dialog, data->error_text_buffer, sizeof(data->error_text_buffer))
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
{ health_util_format_hours_and_minutes(buffer + avg_len, buffer_size - avg_len, daily_avg, i18n_owner); }
sert_equal_i(prv_count_scheduled_animations(), 0); // Make sure just the setup and teardown handlers were called cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 1); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 0); cl_assert_equal_i(prv_count_handler_entries...
cl_assert(animation_get_implementation(h) == &implementation2.base)
; // Custom Curve cl_assert(animation_get_custom_curve(h) != prv_custom_curve); animation_set_custom_curve(h, prv_custom_curve); cl_assert(animation_get_custom_curve(h) == prv_custom_curve); // Reverse cl_assert(animation_get_reverse(h) == false); animation_set_reverse(h, true); cl_assert(animation_...
/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
(crc, "abcdefg", 1)
; assert_equal_hex(crc, 0xe8b7be43); } void test_crc32__standard_check(void) { // "Check" value from "A Painless Guide to CRC Error Detection Algorithms" crc = crc32(crc, "123456789", 9); assert_equal_hex(crc, 0xCBF43926); } void test_crc32__residue(void) { uint8_t message[30]; memcpy(message, "1234567890...
ance_size += sizeof(SerializedAppGlanceSliceHeader); AttributeList *attr_list = &current_attr_list_data->attr_list; // Initialize the attributes common to all slice types in the attribute list attribute_list_add_uint32(attr_list, AttributeIdTimestamp, (uint32_t)current_slice->...
{ PBL_LOG(LOG_LEVEL_WARNING, "Failed to deserialize an AttributeList from a serialized slice"); return false; }
// Check if the AttributeList has the attributes required for the slice const bool is_attr_list_valid = prv_is_slice_attribute_list_valid(serialized_slice->type, &attr_list); if (!is_attr_list_valid) { PBL_LOG(LOG_LEVEL_WARNING, "Serialized...
ent is sent shortly after. intent->client[c].connected = connected; } } if (task_mask != task_mask_none) { // Send event to the client(s) that need to be notified: const BTBondingID bonding_id = prv_get_bonding_id_for_intent(intent); prv_put_connection_event(task_mask, device, hci_reason, con...
bt_driver_gap_le_disconnect(&event->peer_address)
; break; } const SMIdentityResolvingKey *remote_irk = event->is_resolved ? &event->irk : NULL; GAPLEConnection *connection = gap_le_connection_add(&event->peer_address, remote_irk, local_is_master); // Cache the BLE connection pa...
T("_rocky.on('secondchange', function() {});"); cl_assert_equal_b(true, rocky_global_has_event_handlers("secondchange")); cl_assert_equal_b(true, rocky_global_has_event_handlers("minutechange")); cl_assert_equal_b(true, rocky_global_has_event_handlers("hourchange")); cl_assert_equal_b(true, rocky_global_has_eve...
{ rocky_global_init(s_api); s_log_internal__expected = (const char *[]){ NULL }; const time_t cur_time = 1458250851; // Thu Mar 17 21:40:51 2016 UTC // Thu Mar 17 14:40:51 2016 PDT const uint16_t cur_millis = 123; fake_time_init(cur_time, cur_millis); EXECUTE_SCRIP...
se as it sees fit. if (!worker_state_configure(&worker_ram)) { PBL_LOG(LOG_LEVEL_ERROR, "Worker state configuration failed"); return false; } // The remaining space in worker_segment is assigned to the worker's // heap. Worker state needs to be configured before initializing the // heap as the WorkerS...
{ // This method can be called as a result of receiving a PEBBLE_PROCESS_KILL_EVENT notification // from an app, telling us that it just finished it's deinit. // Shouldn't be called from app. Use process_manager_put_kill_process_event() instead. PBL_ASSERT_TASK(PebbleTask_KernelMain); // If no worker runni...