prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
e == I2CTransferState_WriteRegAddress) {
// For writes, we'll reload with the payload once we send the address. Otherwise, we'd need to
// send a repeated start, which we don't want to do.
const bool reload = bus->state->transfer.direction == I2CTransferDirection_Write;
bus->hal->i2c->CR2 = (bus->state-... | if ((i2c->ISR & I2C_ISR_ARLO) != 0) {
i2c->ICR |= I2C_ICR_ARLOCF;
} |
prv_end_transfer_irq(bus, I2CTransferEvent_Error);
}
void i2c_hal_event_irq_handler(I2CBus *bus) {
prv_event_irq_handler(bus);
}
void i2c_hal_error_irq_handler(I2CBus *bus) {
prv_error_irq_handler(bus);
}
|
0x01, 0x02, 0x03, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x20, 0x21,
0x22, 0x23, 0x24, 0x25, 0x26, 0x30, 0x32, 0x33, 0x35, 0x36,
0x37, 0x39, 0x41, 0x42, 0x43, 0x44, 0x73, 0x74, 0x75, 0x77,
0x78, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x8e,
0x90, 0x91, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac,
0xad, 0xae... | {
// Clear pending interrupts in case we were woken from standby
prv_clear_pending_interrupts();
exti_configure_pin(
BOARD_CONFIG_POWER.pmic_int, ExtiTrigger_Falling, prv_as3701b_interrupt_handler);
exti_enable(BOARD_CONFIG_POWER.pmic_int);
const uint8_t mask = (uint8_t) ~(PmicInt1_LowBat | PmicInt1_C... |
// Set up 160Hz clock which is used for VCOM.
// This setting is a divisor of 16 and a high/low duration of 195us, as
// given in the following: 1000000 / (16 * 195 * 2) = ~160Hz
static void prv_start_160hz_clock(void) {
const uint8_t pwm_high_low_time_us = (195 - 1);
prv_write_register(PmicRegisters_PWM_CNTL_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... | {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_round_rect(ctx, &GRect(2, 2, 28, 20), 4);
} |
void white_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_context_set_antialiased(ctx, false);
graphics_draw_round_rect(ctx, &GRect(2, 2, 28, 20), 4);
}
void clear_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_co... |
rtstrap_comms_init(void) {
s_read_timer = new_timer_create();
s_header_mbuf = MBUF_EMPTY;
mbuf_set_data(&s_header_mbuf, s_header_data, sizeof(s_header_data));
}
// Helper functions for static variables
////////////////////////////////////////////////////////////////////////////////
static void prv_reset_read_i... | ((uint8_t *)&data, sizeof(data), (uint8_t *)&s_read_info.checksum,
false /* !big_endian */) | ;
}
static void prv_handle_complete_frame(bool *should_context_switch) {
FrameHeader *header = mbuf_get_data(&s_header_mbuf);
bool is_notify = header->flags.is_notify;
if ((is_notify && (smartstrap_fsm_state_get() != SmartstrapStateNotifyInProgress)) ||
(!is_notify && (s_read_consumer.profile != header->pr... |
*connection = (Connection) {
.conn_idx = conn_idx,
.initial_addr = *initial_addr,
.local_addr = *local_addr,
.conn_params = *params,
};
s_connections = (Connection *)list_prepend((ListNode *)s_connections, (ListNode *)connection);
}
prv_unlock();
return connection;
}
void connect... | prv_lock() | ;
{
*addr_buf = connection->local_addr;
}
prv_unlock();
}
void connection_get_conn_params(const Connection *connection,
BleConnectionParams *params_out) {
prv_lock();
{
*params_out = connection->conn_params;
}
prv_unlock();
}
void connection_get_address_by_idx_che... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_LOG(LOG_LEVEL_DEBUG, ">> Flash operation time!") | |
led(animation), false);
animation_schedule(animation);
animation_set_elapsed(animation, 20);
animation_set_duration(animation, ANIMATION_DURATION_INFINITE);
prv_play_animation_update(animation, 0); // intentionally bad value
cl_assert_equal_i(kino_reel_get_elapsed(test_reel), 20);
}
void test_kino_player_... | prv_play_animation_update(animation, 0) | ; // intentionally bad value
cl_assert_equal_i(kino_reel_get_elapsed(test_reel), ANIMATION_DURATION_INFINITE);
}
void test_kino_player__infinite_animation_infinite_reel_reverse(void) {
// Choose duration and elapsed to have clean division for
// ANIMATION_NORMALIZED_MAX * elapsed / duration = whole_number
te... |
reason.h"
#include "system/reset.h"
#include "util/math.h"
#include "util/net.h"
#include "util/string.h"
#define CMSIS_COMPATIBLE
#include <mcu.h>
#include <bluetooth/bt_test.h>
#include <bluetooth/responsiveness.h>
#include <bluetooth/gatt_discovery.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
... | (buffer, address, read_length) | ;
// Output to serial
for (uint32_t i = 0; i < read_length; i++) {
dbgserial_putchar(buffer[i]);
}
address += read_length;
length -= read_length;
}
kernel_free(buffer);
}
void command_flash_switch_mode (const char* mode_str) {
int mode = atoi(mode_str);
flash_switch_mode(mode);
}
... |
F ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "health_util.h"
#include "services/common/i18n/i18n.h"
#include "services/normal/activity/activity.h"
#include "shell/prefs.h"
#include "util/time/time.h"
#inclu... | i18n_get("%d", i18n_owner) | , hours);
GTextNodeText *hours_units_text_node = health_util_create_text_node_with_text(
i18n_get("H", i18n_owner), units_font, color, container);
hours_units_text_node->node.offset.y = units_offset_y;
}
if (hours != INT_MIN && minutes != INT_MIN) {
// add a space between the H and the number ... |
YTES_ALREADY_IN_PROGRESS) {
s_get_bytes_in_progress = false;
}
prv_put_status_event(DebugInfoStateFinished);
return true;
}
static void prv_gather_and_record_stats(GetBytesState *state) {
uint32_t elapsed_time_ms = ticks_to_milliseconds(rtc_get_ticks() - state->start_ticks);
uint32_t bytes_per_sec = ((... | comm_session_set_responsiveness(state->session, BtConsumerPpGetBytes, ResponseTimeMax, 0) | |
ssert_equal_i(music_get_playback_rate_percent(), 200);
}
void test_ams__receive_player_playback_info_update_nulls(void) {
prv_connect_ams();
// Receive: paused, empty string, empty string
// 0000 00 01 00 30 2c 2c ...0,,
uint8_t playback_info_update[] = {
0x00, 0x01, 0x00... | (title, NULL, NULL) | ;
cl_assert_equal_s(title, "So What");
}
void test_ams__receive_track_album_update(void) {
prv_connect_ams();
// 0000 02 01 00 4b 69 6e 64 20 4f 66 20 42 6c 75 65 20 ...Kind Of Blue
// 0010 28 4c 65 67 61 63 79 20 45 64 69 74 69 6f 6e 29 (Legacy Edition)
uint8_t track_album_update[] = {
0x02,... |
0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4};
TimelineItem e = {
.header = {
.id = id,
.status = 0,
.layout = LayoutIdGeneric,
.type = TimelineItemTypeNotification,
},
.attr_list = {
.num_attributes = ARRAY_LENGTH(attributes),
.at... | ARRAY_LENGTH(actions) | |
sing the data subscription, disable it
sys_vibe_history_stop_collecting();
accel_set_num_samples(0);
} else {
// Else, reconfigure for the common subset of requirements among remaining subscribers
prv_update_driver_config();
}
}
}
mutex_unlock_recursive(s_mutex);
}
... | mutex_lock_recursive(s_mutex) | ;
AccelSubscriberState* state = prv_subscriber_state(session);
state->task = task;
mutex_unlock_recursive(s_mutex);
}
|
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.
*/
#include "applib/app_message/app_message_intern... | prv_request_fast_connection(app_message_send_job->session) | ;
const size_t length_available = prv_get_length(app_message_send_job);
const size_t length_after_offset = (length_available - start_offset);
const size_t length_to_copy = MIN(length_after_offset, length);
size_t length_remaining = length_to_copy;
while (length_remaining) {
const uint8_t *part_data;
... |
/*
* 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... | {
state_x[k] = state_x[k - 1];
} |
state_x[0] = x;
// Factor in the x * b elements
Fixed_S64_32 ytmp = Fixed_S64_32_mul(cb[0], state_x[0]);
for (int i = 1; i < num_input_coefficients; i++) {
ytmp = Fixed_S64_32_add(ytmp, Fixed_S64_32_mul(cb[i], state_x[i]));
}
// Factor in the y * a coeficients
for (int i = 0; i < num_output_coeffic... |
L_REG_INDEX_LR] = sp[5];
packed_info.registers[portCANONICAL_REG_INDEX_PC] = sp[6];
packed_info.registers[portCANONICAL_REG_INDEX_XPSR] = sp[7];
// Pop the exception stack frame, taking stack alignment into account.
// The 10th bit of the pushed xPSR indicates whether an alignment word was
... | {
CoreDumpImageHeader hdr = {
.magic = CORE_DUMP_MAGIC,
.core_number = core_number,
.version = CORE_DUMP_VERSION,
.time_stamp = timestamp,
};
strncpy((char *)hdr.serial_number, mfg_get_serial_number(), sizeof(hdr.serial_number));
hdr.serial_number[sizeof(hdr.serial_number)-1] = 0;
version_copy... |
// =================================================================================================
// Public interface
// -----------------------------------------------------------------------------------------------
// Trigger a core dump
NORETURN core_dump_reset(bool is_forced) {
// Big problem if we re-enter... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
Window window;
window_init(&window, WINDOW_NAME("Health"));
Layer *window_layer = window_get_root_layer(&window);
Layer *card_layer = health_activity_summary_card_create(health_data);
layer_set_frame(card_layer, &window_layer->bounds);
layer_add_child(window_layer, card_layer);
window_set_background_col... |
// Tests
//////////////////////
void test_health_activity_summary_card__render_no_data(void) {
prv_create_card_and_render(&(HealthData) {});
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_health_activity_summary_card__no_current_steps(void) {
HealthData health_data = {
.step_data... |
ut);
cl_check(gbitmap_pbi_eq(s_dest_bitmap, namecat(namecat(__func__, "__with_orphan"), ".pbi")));
}
void test_graphics_draw_text_flow__max_used_size_draw_text_doom(void) {
cl_assert(text_resources_init_font(0, RESOURCE_ID_GOTHIC_24_BOLD, 0, &s_font_info));
TextLayoutExtended layout = {
.flow_data = {
... | graphics_draw_line(&ctx, GPoint(0, second_page_start_y), GPoint(180, second_page_start_y)) | |
e bounds of REGISTRY_FLASH_BEGIN and
//! REGISTRY_FLASH_END.
static void prv_assert_valid_cursor(const RegistryCursor *cursor) {
const bool is_addr_subsector_aligned = (cursor->address % (SUBSECTOR_SIZE_BYTES)) == 0;
PBL_ASSERTN(is_addr_subsector_aligned &&
cursor->address >= cursor->begin &&
... | (registry) | ;
}
prv_assert_valid_cursor(registry->cursor);
}
|
{
static unsigned int original_idx;
if (!revert) {
original_idx = s_next_region_idx;
s_next_region_idx = TOTAL_NUM_FLASH_REGIONS;
} else {
s_next_region_idx = original_idx;
}
s_ftl_size = 0;
for (unsigned int i = 0; i < s_next_region_idx; i++) {
s_ftl_size += prv_region_size(i);
}
PB... | if (offset < curr_virt_offset_end) {
uint32_t bytes = MIN(curr_virt_offset_end - offset, size);
if (operation == FTLRead) {
flash_read_bytes(
buffer, s_region_list[idx].start + offset - curr_virt_offset_begin, bytes);
} else if (operation == FTLWrite ) {
flash_write_bytes(... | |
/*
* 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 (s_comm_enabled) {
if (s_comm_override == BtCtlModeOverrideRun) {
return true;
} else if (s_comm_override == BtCtlModeOverrideNone && !s_comm_airplane_mode_on) {
return 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... | system_flash_erase(FLASH_BASE, 1024 KiB, NULL, NULL) | );
cl_assert_equal_i(BITS_BETWEEN(0, 7), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_sector_0(void) {
cl_assert(system_flash_erase(FLASH_BASE, 16 KiB, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_16K... |
ROCKY_ARG(s32),
ROCKY_ARG(s64),
ROCKY_ARG(d),
);
ASSERT_JS_ERROR(error_value, c->expected_error_msg);
if (!c->expected_error_msg) {
cl_assert_equal_i(u8, (uint8_t)c->u8);
cl_assert_equal_i(u16, (uint16_t)c->u16);
cl_assert_equal_i(u32, (uint32_t)c->u32);
cl_assert_eq... | jerry_create_string((const jerry_char_t *)"") | ,
.expected_output = "",
},
{
.input = jerry_create_string((const jerry_char_t *)"js"),
.expected_output = "js",
},
{
.input = jerry_create_null(),
.expected_output = "null",
},
{
.input = jerry_create_undefined(),
.expected_output = "undefined",
},
... |
e can pass in the GBitmapFormat
// we need to use for the unit test output canvas instead of relying on GBITMAP_NATIVE_FORMAT, which
// wouldn't work for Spalding since it uses GBitmapFormat8BitCircular
GBitmap* graphics_capture_frame_buffer(GContext *ctx) {
PBL_ASSERTN(ctx);
return graphics_capture_frame_buffer_fo... | system_theme_set_content_size(content_size) | |
e = NULL;
// Common for most tests:
s_firmware_update_is_in_progress = true;
fake_spi_flash_init(0, 0x1000000);
put_bytes_init();
}
void test_put_bytes__cleanup(void) {
put_bytes_deinit();
fake_comm_session_cleanup();
fake_system_task_callbacks_cleanup();
fake_event_clear_last();
fake_pbl_malloc... | assert_nack_count(1) | ;
}
void test_put_bytes__init_invalid_object_type(void) {
PutBytesObjectType invalid_object_type = 0xff;
prv_receive_init(VALID_OBJECT_SIZE, invalid_object_type);
// Fail due to massive total_size in our init message
assert_ack_count(0);
assert_nack_count(1);
}
void test_put_bytes__init_firmware_object_whi... |
cense is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "services/common/shared_prf_storage/shared_prf_storage.h"
#include "services/common... | kernel_zalloc(SPRF_REGION_SIZE) | ;
flash_write_bytes(flash_buf, FLASH_REGION_SHARED_PRF_STORAGE_BEGIN, SPRF_REGION_SIZE);
shared_prf_storage_init();
shared_prf_storage_set_getting_started_complete(true);
cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), true);
}
void test_shared_prf_storage_v3__find_first_valid_sector(void)... |
mber of multi-clicks before the multi_click.handler gets fired
static const uint8_t MULTI_CLICK_DEFAULT_MIN = 2;
//! Default timeout after which looking for follow up clicks will be stopped
static const uint32_t MULTI_CLICK_DEFAULT_TIMEOUT_MS = 300;
//! Default delay before long click is fired
static const uint32_t LON... | prv_is_multi_click_enabled(recognizer) | ) {
return 0;
}
if (recognizer->config.multi_click.max == 0) {
return prv_multi_click_get_min(recognizer);
}
return recognizer->config.multi_click.max;
}
static uint32_t prv_multi_click_get_timeout(ClickRecognizer *recognizer) {
if (false == prv_is_multi_click_enabled(recognizer)) {
return 0;
}... |
sume(buffer, client, chunk));
buffer += chunk;
num_bytes -= chunk;
}
}
void test_shared_circular_buffer__one_client(void) {
SharedCircularBuffer buffer;
uint8_t storage[9];
shared_circular_buffer_init(&buffer, storage, sizeof(storage));
const uint8_t* out_buffer;
uint16_t out_length;
// Add a ... | (shared_circular_buffer_read(&buffer, &client1, 4, &out_buffer, &out_length)) | |
subscribers;
while (state) {
uint16_t new_num, new_den;
if ((highest_rate % state->sampling_rate) == 0) {
new_num = 1;
new_den = highest_rate / state->sampling_rate;
} else {
PBL_ASSERTN(highest_rate == ACCEL_SAMPLING_25HZ
&& state->sampling_rate == ACCEL_SAMPLING_10HZ)... | ACCEL_LOG_DEBUG("setting FIFO to 1 deep for peek") | ;
accel_set_num_samples(1);
s_accel_samples_per_update = 1;
// Set a timer to restore settings after a while
prv_set_restore_fifo_mode_timer();
int max_loops = 12;
result = -3;
while (max_loops--) {
accel_data->timestamp = accel_get_latest_timestamp();
if (acc... |
to-date data
text_layer_set_text(text[TextBack], NULL);
text_layer_set_text(text[TextMid], NULL);
text_layer_set_text(text[TextFront], NULL);
text_layer_set_text(text[TextPar], "-");
text_layer_set_text(text[TextHole], "-");
} else {
// Return text to normal size. Display '...' while waiting f... | {
text_layer_set_font(text_layer, fonts_get_system_font(font_key));
text_layer_set_text(text_layer, text);
text_layer_set_text_alignment(text_layer, alignment);
text_layer_set_text_color(text_layer, GColorBlack);
text_layer_set_background_color(text_layer, GColorClear);
} |
static void window_load(Window *window) {
AppData *data = &s_data;
// Action bar icon bitmaps.
data->up_bitmap = gbitmap_create_from_png_data(s_golf_api_up_icon_png_data,
sizeof(s_golf_api_up_icon_png_data));
data->down_bitmap = gbitmap_create_from_png_data(s_... |
1);
cl_assert(!manager.triggered);
cl_assert(!manager.active_layer);
cl_assert_equal_i(manager.state, RecognizerManagerState_WaitForTouchdown);
cl_assert_equal_i(r2->state, RecognizerState_Possible);
cl_assert(!recognizer_get_manager(r1));
recognizer_set_manager(r1, &manager);
r1->state = RecognizerState... | cl_assert_equal_p(manager.active_layer, NULL) | ;
prv_compare_recognizers_processed((int []) { 0, 1 }, 2, &s_recognizers_reset);
cl_assert_equal_i(r[0]->state, RecognizerState_Possible);
cl_assert_equal_i(r[1]->state, RecognizerState_Possible);
r[0]->state = RecognizerState_Completed;
manager.active_layer = &layer_a;
manager.state = RecognizerManagerSta... |
528},
{ 336, 1080, 560},
{ 344, 1032, 824},
{ 320, 920, 864},
{ 408, 1032, 952},
{ -24, 896, 808},
{ 168, 752, 616},
{ 184, 608, 600},
{ 160, 616, 568},
{ 160, 672, 616},
{ 184, 744, 544},
{ 216, 696, 552},
{ 320, 672, 504},
{ 272, 888, 768},
{ 0, 560, 864},
{... | { 256, 824, 640},
{ 248, 1192, 576},
{ 200, 800, 480},
{ 160, 1256, 640},
{ -72, 920, 528},
{ 152, 880, 64},
{ 184, 600, 344},
{ 144, 872, 248},
{ 16, 936, 400},
{ 120, 904, 256},
{ 160, 768, 232},
{ 184, 712, 200},
// 50 seconds
{ 200, 704, 344},
{ 160, 816, ... |
// ----------------------------------------------------------------
// Sample captured: 2015-10-05 15:50:58 local
AccelRawData *activity_sample_walk_100_pbl_25672_6(int *len) {
// The unit tests parse the //> TEST_.* lines below for test values
//> TEST_NAME walk_100_pbl_25672_6
//> TEST_EXPECTED 100
//> T... |
s in the attribute list
s_slice_type_impls[current_slice->type].init_attr_list_from_slice(current_slice, attr_list);
// Record size of the attribute list in the data struct as well as the overall size accumulator
current_attr_list_data->attr_list_size = attribute_list_get_serialized_size(attr_list);
se... | {
PBL_LOG(LOG_LEVEL_WARNING, "Serialized slice AttributeList is invalid");
} |
attribute_list_destroy_list(&attr_list);
kernel_free(attr_list_data_buffer);
return is_attr_list_valid;
}
typedef struct SliceValidationIteratorContext {
bool is_at_least_one_slice_invalid;
size_t validated_size;
} SliceValidationIteratorContext;
//! If any slices are invalid, context.is_at_least_one_sli... |
6, 480, 16},
{ -1728, 632, -224},
{ -1304, 608, -72},
{ -1008, 552, -200},
{ -1056, 600, -160},
{ -936, 432, -40},
{ -648, 304, 48},
{ -504, 264, 88},
{ -448, 216, 0},
{ -552, 296, 32},
{ -536, 104, 176},
{ -544, 64, 168},
{ -656, 216, 80},
{ -888, 288, 96},
{ -11... | { -384, 168, -136},
{ -344, 312, -216},
{ -440, 352, -184},
{ -536, 288, -40},
{ -696, 288, 8},
{ -656, 320, 8},
{ -784, 392, -56},
{ -992, 424, -64},
{ -1056, 344, 72},
// 50 seconds
{ -1544, 488, -88},
{ -1408, 536, -64},
{ -976, 552, -96},
{ -1192, 712, -272},
... |
{ -968, 432, -160},
{ -1056, 352, -16},
{ -1560, 408, -104},
{ -1328, 512, -88},
{ -968, 440, -48},
{ -1128, 640, -224},
{ -920, 392, 8},
{ -664, 280, 48},
{ -520, 344, -48},
{ -488, 336, -24},
{ -488, 264, 40},
{ -544, 232, 88},
{ -600, 232, 112},
{ -688, 264, 1... |
Test registring and cancelling a metric alert
HealthMetricAlert *alert = health_service_register_metric_alert(HealthMetricHeartRateBPM, 10);
APP_LOG(APP_LOG_LEVEL_DEBUG, "Result from register_metric_alert: %p", alert);
if (alert == NULL) {
passed = false;
goto exit;
}
bool success = health_service_ca... | layer_add_child(window_layer, simple_menu_layer_get_layer(data->debug_card.menu_layer)) | ;
}
// -------------------------------------------------------------------------------
static void debug_window_unload(Window *window) {
simple_menu_layer_destroy(s_data->debug_card.menu_layer);
}
// -------------------------------------------------------------------------------
static void deinit(void) {
windo... |
alerts_set_mask(AlertMaskAllOn);
}
void test_alerts__cleanup(void) {
}
// Tests
/////////////////////////////////
void test_alerts__enabled(void) {
alerts_set_mask(AlertMaskAllOn);
cl_assert(alerts_get_mask() == AlertMaskAllOn);
// Should allow all notifications to go through
cl_assert(alerts_should_noti... | cl_assert(alerts_should_vibrate_for_type(AlertPhoneCall)) | ;
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(alerts_should_enable_backlight_for_type(AlertPhoneCall));
cl_assert(alerts_should_notify_for_type(AlertMobile));
cl_assert(!alerts_should_vibrate_for_type(AlertMobile));
alerts_set_n... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (distance_normalized,
property_animation->values.from.uint32,
property_animation->values.to.uint32) | ;
((PropertyAnimationImplementation*)
property_animation->animation.implementation)
->accessors.setter.uint32(property_animation->subject, result);
}
// -----------------------------------------------------------------------------------------
void property_animation_update_gpoint(PropertyAnimation *proper... |
&data->event_service_info);
prv_cancel_response_timer(data);
applib_free(data);
}
static void prv_show_result_window(ActionResultData *data, const TimelineResourceId timeline_res_id,
const char *msg, bool succeeded) {
const GSize simple_dialog_icon_size = timeline_resources_get... | prv_show_result_window(data, data->dialog.icon, data->dialog.message, data->dialog.success) | |
/*
* 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... | (&layer, &ctx) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_across_x_origin_layer.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &across_nx_layer_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_across_nx_origin... |
(PEBBLE_UNOBSTRUCTED_AREA_EVENT) | ->handler);
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.did_change, prv_did_change);
const GRect from_area = GRect(0, 0, DISP_COLS, 400);
const GRect to_area = GRect(0, 0, DISP_COLS, 200);
unobstructed_area_service_will_change(from_area.size.h, to_area.size.h);
fake_event_service_hand... | |
/*
* 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 (src_color.a == 0) {
// Fast path: 0% opacity, no-op!
} else {
const GColor8 dest_color = *dst;
const uint8_t f_src = src_color.a;
const uint8_t f_dst = 3 - f_src;
GColor8 final = {};
final.r = (src_color.r * f_src + dest_color.r * f_dst) / 3;
final.g = (src_color.g * f_src + dest_color.g *... |
}
GBitmapSequence *gbitmap_sequence_create_with_resource(uint32_t resource_id) {
ResAppNum app_num = sys_get_current_resource_num();
return gbitmap_sequence_create_with_resource_system(app_num, resource_id);
}
GBitmapSequence *gbitmap_sequence_create_with_resource_system(ResAppNum app_num,
... |
rue);
modal_window_push(window2, base_priority - 1, false);
cl_assert_equal_i(window1->on_screen, true);
cl_assert_equal_i(window2->on_screen, false);
modal_window_push(window1, base_priority - 2, false);
modal_manager_event_loop_upkeep();
cl_assert_equal_i(window1->on_screen, false);
cl_assert_equal... | cl_check(!modal_stack->list_head) | |
using infinite loop the next time this is
// called
if (sibling == child) {
PBL_LOG(LOG_LEVEL_DEBUG, "Layer has already been added to this parent!");
return;
}
if (!sibling->next_sibling) {
break;
}
sibling = sibling->next_sibling;
}
sibling->next_sibling = child;
}
// Be... | (layer, point) | ;
}
#endif
return grect_contains_point(&layer->frame, point);
}
void layer_set_contains_point_override(Layer *layer, LayerContainsPointOverride override) {
if (!layer) {
return;
}
#if CAPABILITY_HAS_TOUCHSCREEN
layer->contains_point_override = override;
#endif
}
typedef struct LayerContainsPointIterCtx ... |
comm_session_get_system_session() | ;
comm_session_send_data(system_session, ENDPOINT_ID, buffer, sizeof(buffer), COMM_SESSION_DEFAULT_TIMEOUT);
PBL_LOG(LOG_LEVEL_DEBUG, "Sending sysmsg: %u", type);
}
static void prv_reset_kernel_bg_cb(void *unused) {
PBL_LOG(LOG_LEVEL_ALWAYS, "Rebooting to install firmware...");
RebootReason reason = { RebootRe... | |
string_strip_trailing_whitespace(with_both, string_out) | ;
cl_assert(strcmp(with_neither, string_out) == 0);
}
void test_string__test_concat_str_int(void) {
char buf[32];
concat_str_int("app", 1, buf, sizeof(buf));
cl_assert_equal_s(buf, "app1");
concat_str_int("app", 255, buf, sizeof(buf));
cl_assert_equal_s(buf, "app255");
concat_str_int("res_bank", 1, bu... | |
KinoLayer connectivity_icon;
uint32_t connectivity_icon_id;
KinoLayer battery_icon;
uint32_t battery_icon_id;
} LauncherMenuData;
typedef struct LauncherMenuPersistedData {
int scroll_offset_y;
int menu_index_row;
bool valid;
RtcTicks leave_time;
} LauncherMenuPersistedData;
static LauncherMenuPersiste... | (&(AppLaunchEventConfig) {
.id = node->install_id,
.common.reason = APP_LAUNCH_USER,
.common.button = BUTTON_ID_SELECT,
}) | ;
}
static uint16_t get_num_rows_callback(MenuLayer *menu_layer, uint16_t section_index,
LauncherMenuData *data) {
return app_menu_data_source_get_count(&data->data_source);
}
static void draw_row_callback(GContext *ctx, Layer *cell_layer, MenuIndex *cell_index,
... |
/*
* 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... | ((TestSendJob *)send_job) | ;
}
size_t prv_send_job_impl_copy(const SessionSendQueueJob *send_job, int start_offset,
size_t length, uint8_t *data_out) {
TestSendJob *sb = (TestSendJob *)send_job;
const size_t length_remaining = prv_get_length(sb);
const size_t length_after_offset = (length_remaining - start_of... |
flight so far.
const bool is_cancelled = app_outbox_service_is_message_cancelled(outbox_message);
if (is_cancelled) {
static const uint32_t s_zeroes = 0;
*data_out = (const uint8_t *)&s_zeroes;
return sizeof(s_zeroes);
}
const AppMessageAppOutboxData *outbox_data =
(const App... | {
return (endpoint_id == APP_MESSAGE_ENDPOINT_ID);
} |
static AppMessageSenderError prv_sanity_check_msg_and_fill_header(const AppOutboxMessage *message) {
if (message->length < (sizeof(AppMessageAppOutboxData) + 1 /* Prohibit zero length PP msg */)) {
return AppMessageSenderErrorDataTooShort;
}
const AppMessageAppOutboxData *outbox_data = (const AppMessageApp... |
uint8_t idx = y*line_stride + (x/(ppb));
const uint8_t shift = (8 - bpp) - bpp * (x % ppb);
const uint8_t mask = ~(((1 << bpp) - 1) << shift);
buf[idx] = buf[idx] & mask;
buf[idx] |= ((color_index & ((1 << bpp) - 1)) << shift);
}
static bool prv_check_source_stripe_blit(const uint8_t *data,
... | gcolor_equal(get_bitmap_color(&s_bmp, x, y), s_palette[x]) | , print_buf);
}
}
#endif
bitblt_bitmap_into_bitmap(&dest_bitmap, &s_bmp, GPointZero, GCompOpAssign, GColorWhite);
cl_assert(prv_check_source_stripe_blit(dest_bitmap_data, &s_bmp, GColorWhite));
}
static void prv_opaque_2bit_simple(GCompOp compositing_mode) {
const int BITS_PER_PIXEL = 2;
const int PIXE... |
ut_size = 8;
uint8_t data_out[data_out_size];
// Test copy when there is nothing in the buffer:
cl_assert_equal_i(circular_buffer_copy(&buffer, data_out, data_out_size), 0);
// Write + consume, so read index is at 2:
circular_buffer_write(&buffer, (uint8_t *)"0123", 4);
circular_buffer_consume(&buffer, 2)... | memcpy(data_out, "AB", 2) | |
= 266668 }, // priority rank 49
{ .id = 42, .priority = 58, .size = 61228 }, // priority rank 46
{ .id = 43, .priority = 12, .size = 23513 }, // priority rank 7
{ .id = 44, .priority = 60, .size = 267049 }, // priority rank 47
{ .id = 45, .priority = 52, .size = 240086 }, // priority rank 40
{ .id = 46, .p... | if (fd < 0) {
return false;
} |
pfs_close(fd);
return true;
}
static void prv_create_file_for_id(AppInstallId id) {
char buffer[30];
itoa_int(id, buffer, 10);
int fd = pfs_open(buffer, OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
pfs_close(fd);
}
void test_app_cache__delete_binaries_for_id_with_no_entry(void) {
// confirm binaries get crea... |
t_record(&input, false /* use_data_logging */, session_ref);
prv_assert_msg_equal(&input, msg);
// ------------------
// Send another set of measurements
uint32_t offset_sec_b[] = {2, 4, 6};
uint32_t values_b[] = {0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666};
input = (TestPLParsedMsg) {
.type = Pr... | (session_ref) | |
the previous retry counter doesn't affect any new discovery process:
fake_event_clear_last();
cl_assert_equal_i(gatt_client_discovery_discover_all(&device), BTErrnoOK);
// Fire watchdog one less time than the maximum:
prv_fire_watchdog_timeouts(&device, GATT_CLIENT_DISCOVERY_MAX_RETRY - 1);
// Finally make ... | gatt_client_discovery_rediscover_all(&device) | , BTErrnoOK);
// Assert the previous process has been stopped:
cl_assert_equal_i(stop_count_before_rediscovery + 1, fake_gatt_is_service_discovery_stop_count());
// Expect "Database Changed" event:
prv_assert_event(&device, BTErrnoServiceDiscoveryDatabaseChanged);
// Put one, expect one:
prv_simulate_and... |
er(1000, prv_update_timer_callback, active_window);
const int bpm = active_window->workout_controller->get_metric_value(
WorkoutMetricType_Hr, active_window->workout_data);
if (bpm == 0 && !active_window->hr_measuring_timer) {
active_window->cur_hr_measuring_width_idx = 0;
prv_hr_measuring_timer_call... | (ctx, &zone_rect) | |
tion, CPOL, CPHA, baudrate prescaler and first-bit come from the device config
tmpreg |= (uint16_t)((uint32_t)slave->spi_direction | SpiMode_Master |
SpiDataSize_8b | slave->spi_cpol |
slave->spi_cpha | SpiSlaveSelect_Soft |
prescaler | slave->spi_first_bit);
// Write result back to CR1
bus->spi->CR1 ... | {
prv_spi_acquire_helper(slave);
spi_ll_slave_burst_read_write(slave, out, in, len);
prv_spi_release_helper(slave);
} |
void spi_slave_burst_read_write_scatter(const SPISlavePort *slave,
const SPIScatterGather *sc_info,
size_t num_sg) {
prv_spi_acquire_helper(slave);
spi_ll_slave_burst_read_write_scatter(slave, sc_info, num_sg);
prv_spi_release_helper(slave);
}
void spi_... |
tical_line_raw(void) {
prv_mask_apply_vline_test_pattern(prv_vline_pattern_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) {
//... | graphics_context_mask_create(ctx, true /* transparent */) | ;
cl_assert(mask1);
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);
GD... |
n(
GAPLEConnection *connection, GATTService *service, BTErrno error) {
// We experienced some kind of conversion error, pass it on
if (error != BTErrnoOK) {
prv_send_services_added_event(connection, error);
return;
}
GATTServiceNode *node = kernel_zalloc_check(sizeof(GATTServiceNode));
node->ser... | (connection) | ;
} else {
// Queue up CCCD writes to unsubscribe all the subscriptions:
gatt_client_subscriptions_cleanup_by_connection(connection, true /* should_unsubscribe */);
}
prv_finalize_discovery(connection, BTErrnoServiceDiscoveryDatabaseChanged);
ret_val = gatt_client_discovery_disco... |
after_disconnection(void) {
// Device A subscribes:
bt_driver_cb_hrm_service_update_subscription(s_device_a, true);
// Fake disconnection:
s_connections[0] = NULL;
// Grabt permission after disconnection.
// Request object should be freed and thing shouldn't crash.
prv_assert_permissions_ui_and_respond(... | prv_put_and_assert_hrm_event(HRMEvent_BPM, 80, HRMQuality_NoAccel,
true /* expect bt driver cb */, false /* expected_is_on_wrist */) | ;
prv_put_and_assert_hrm_event(HRMEvent_BPM, 80, HRMQuality_OffWrist,
true /* expect bt driver cb */, false /* expected_is_on_wrist */);
// Ignore non-BPM event:
prv_put_and_assert_hrm_event(HRMEvent_HRV, 80, HRMQuality_OffWrist,
false /* expect bt d... |
_text_layer);
text_layer_deinit(&s_phone_ui_data->caller_id_text_layer);
evented_timer_cancel(s_phone_ui_data->call_duration_timer);
evented_timer_cancel(s_phone_ui_data->window_pop_timer);
action_bar_layer_deinit(&s_phone_ui_data->action_bar);
i18n_free_all(s_phone_ui_data);
prv_stop_ringing();
wind... | (&s_phone_ui_data->icon_layer, GAlignCenter) | ;
layer_add_child(&s_phone_ui_data->core_ui_container, &s_phone_ui_data->icon_layer.layer);
// Caller ID text
const GRect caller_id_text_rect = GRect(TEXT_MARGIN_WIDTH, style->caller_id_pos_y,
width, style->caller_id_height);
text_layer_init_with_parameters(&s_phone_ui... |
-984},
{ -152, -144, -984},
{ -144, -168, -976},
// 41 seconds
{ -136, -152, -992},
{ -144, -168, -1000},
{ -144, -168, -992},
{ -144, -160, -992},
{ -144, -176, -992},
{ -152, -160, -984},
{ -160, -144, -976},
{ -160, -128, -1032},
{ -152, -168, -1000},
{ -136, -176... | { -184, -72, -968},
{ -184, -80, -992},
{ -184, -64, -984},
{ -192, -104, -984},
{ -176, -128, -992},
{ -176, -136, -1008},
{ -176, -160, -992},
{ -176, -144, -984},
{ -176, -120, -992},
{ -184, -144, -992},
{ -184, -120, -984},
{ -176, -144, -992},
{ -176, -128, -992... | |
ock();
circular_buffer_consume(&s_tx_buffer, tx_len);
prv_unlock();
// Send the footer
spi_transfer_data tx_footer_transfer = {
.wbuf = &tx_footer,
.length = sizeof(tx_footer),
};
prv_do_blocking_spi_transfer(dev, &tx_footer_transfer);
HOST_TRANSPORT_DEBUG_LOG("Sent %u bytes."... | (&s_tx_buffer, buffer, length) | ;
prv_unlock();
if (success) {
prv_disable_spi_cs_wakeup_interrupt_handling_and_unblock_transaction_loop();
return HostTransportEnqueueStatus_Success;
}
PBL_LOG(LOG_LEVEL_DEBUG, "Failed to enqueue %u bytes", length);
return HostTransportEnqueueStatus_RetryLater;
}
size_t host_transport_rx_get_lengt... |
);
cl_assert(timer_id != TIMER_INVALID_ID);
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(10*60, stub_new_timer_timeout(timer_id) / 1000);
}
void test_calendar_handle__future_event_added_and_removed(void) {
timeline_event_init();
cl_assert_equal_i(fake_event_get_count(), 1);
cl_assert... | stub_new_timer_get_next() | ;
cl_assert(timer_id != TIMER_INVALID_ID);
cl_assert(stub_new_timer_is_scheduled(timer_id));
cl_assert_equal_i(10*60, stub_new_timer_timeout(timer_id) / 1000);
rtc_set_time(10 * 60);
cl_assert(stub_new_timer_fire(timer_id));
cl_assert_equal_i(fake_event_get_count(), 2);
cl_assert(prv_get_calendar_ongoing... |
dData *ad_b = create_ad("B", NULL);
GAPLEAdvertisingJobRef job_b;
job_b = gap_le_advert_schedule(ad_b,
advert_terms_b, sizeof(advert_terms_b)/sizeof(GAPLEAdvertisingJobTerm),
unscheduled_callback, s_unscheduled_cb_data, 0);
// Even though B is new... | (s_unscheduled_cb_count, 1) | ;
cl_assert_equal_p(s_unscheduled_job, job_b);
cl_assert_equal_b(s_unscheduled_completed, true);
// Unschedule job "A"
regular_timer_fire_seconds(1);
cl_assert_equal_i(s_unscheduled_cb_count, 2);
cl_assert_equal_p(s_unscheduled_job, job_a);
cl_assert_equal_b(s_unscheduled_completed, true);
cl_assert(!... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | PBL_IF_COLOR_ELSE(GColorBlue, GColorDarkGray) | );
app_window_stack_push(spinner_window, false /* animated */);
// Factory reset on KernelBG so the animation gets priority
system_task_add_callback(prv_factory_reset, NULL);
}
#ifdef RECOVERY_FW
static void prv_mfg_mode_cb(void *data) {
#if CAPABILITY_HAS_ACCESSORY_CONNECTOR
accessory_imaging_enable();
#endi... |
ntext_init(&ctx, fb);
layer_init(&canvas, &GRect(0, 0, 144, 168));
layer_set_update_proc(&canvas, &canvas_layer_update_callback);
layer_init(&layer, &GRect(40, 40, 80, 40));
layer_add_child(&canvas, &layer);
// Corner cases
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text... | (&canvas, &ctx) | ;
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_text_single_line_wordwrap_clip_across_y_second_line.${BIT_DEPTH_NAME}.pbi"));
test_graphics_context_reset(&ctx, fb);
layer_set_update_proc(&layer, &draw_text_single_line_wordwrap_clip_across_nx);
layer_render_tree(&canvas, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.... |
ck_get_time_tm(¤t_time);
time_selection_window->time_data.hour = current_time.tm_hour;
time_selection_window->time_data.minute = current_time.tm_min;
}
void time_selection_window_configure(TimeSelectionWindowData *time_selection_window,
const TimeSelectionWindowConfig *co... | (GColorBlack, GColorWhite) | |
},
.timestamp = 14000,
.duration = 30,
.type = TimelineItemTypePin,
.flags = 0,
.layout = LayoutIdTest,
}
},
{
.header = {
.id = {0xdd},
.timestamp = 16000,
.duration = 30,
.type = TimelineItemTypePin,
.flags = 0,
.layout = LayoutIdTest,
... | uuid_equal(&state.pin.header.id, &s_items[0].header.id) | |
_h, AnimationCurve curve,
void *function) {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
if (animation_private_using_legacy_2(state)) {
if (curve != AnimationCurveCustomFunction) {
// 2.x doesn't support AnimationCurveCustomInterpolatio... | {
return false;
} |
return animation->immutable;
}
// -------------------------------------------------------------------------------------------
bool animation_set_reverse(Animation *animation_h, bool reverse) {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
if (animation_private_using_legacy_2(state)) {
... |
/*
* 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 (uint32_t prescaler = 1; prescaler <= TIMINGR_MAX_PRESC; ++prescaler) {
const uint32_t base_frequency = i2c_clk_frequency / prescaler;
const uint64_t base_period_ps = PS_PER_S / base_frequency;
// Calculate what the total SCL period should be in terms of base clock cycles and then
// recalculate th... |
// extra one to the high period arbitrarily.
scl_low += extra_cycles / 2;
scl_high += extra_cycles - (extra_cycles / 2);
// Calculate the SDA setup time delay, which is confusingly referred to as SCLDEL.
uint32_t scl_delay = DIVIDE_CEIL(
(rise_time_ns * PS_PER_NS) + s_timing_data[bus_mode]... |
sturb_is_schedule_enabled(curr_schedule_type);
time_t seconds_until_update;
bool is_enable_next;
int curr_day = time.tm_wday;
if (!curr_schedule_enabled) { // Only next schedule is enabled
is_enable_next = true;
// Depending on the current schedule, determine the first day index of the next schedule
... | {
prv_push_manual_dnd_first_use_dialog(source);
} | else {
if (source == ManualDNDFirstUseSourceSettingsMenu) {
prv_toggle_manual_dnd_from_settings_menu(NULL);
} else {
prv_toggle_manual_dnd_from_action_menu(NULL);
}
}
}
bool do_not_disturb_is_smart_dnd_enabled(void) {
return alerts_preferences_dnd_is_smart_enabled();
}
void do_not_disturb... |
/*
* 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... | gcolor_equal(color, path_layer->fill_color) | |
// it's still a valid value as we assume grect_get_max_x(.bounds) < .row_size_bytes * bpp
// that way this is an efficient implementation of this functions contract
.max_x = grect_get_max_x(&bitmap->bounds) - 1,
};
}
}
MOCKABLE GBitmapDataRowInfo gbitmap_get_data_row_info(const GBitmap *bitmap... | if (!bitmap) {
return 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... | {
prv_putchar('\r');
prv_putchar('\n');
} |
void dbgserial_putstr(const char* str) {
dbgserial_print(str);
dbgserial_newline();
}
void dbgserial_print_hex(uint32_t value) {
char buf[12];
itoa(value, buf, sizeof(buf));
dbgserial_print(buf);
}
|
if (actions & PhoneCallActions_Answer) {
s_phone_ui_data->up_action = prv_answer_click_handler;
up_icon = RESOURCE_ID_ACTION_BAR_ICON_CHECK;
}
if (actions & PhoneCallActions_Reply) {
// Move to top if that place isn't taken
if (!s_phone_ui_data->up_action) {
s_phone_ui_data->up... | (
delay_ms, false /* repeating */, prv_window_pop_cb, NULL) | ;
}
//! Window setup
//! Currently only 1 call window can exist at a time
static void prv_phone_ui_init(void) {
PBL_ASSERTN(s_phone_ui_data == NULL);
s_phone_ui_data = kernel_zalloc_check(sizeof(PhoneUIData));
s_phone_ui_data->hid_action_bar = false;
s_phone_ui_data->style = s_phone_styles[system_theme_get_c... |
nt(1);
}
static void prv_cancel_before_write_second_message(void) {
put_bytes_cancel();
}
void test_put_bytes__cancel_between_prepare_and_finish(void) {
// When the put_bytes_cancel() is called while the PutBytes message is written (between "prepare"
// and "finish"), expect to receive a Nack:
prv_receive_in... | assert_ack_count(1) | ;
assert_nack_count(0);
}
void test_put_bytes__init_worker_okay_while_not_in_fw_update_mode(void) {
s_firmware_update_is_in_progress = false;
prv_receive_init_cookie(VALID_OBJECT_SIZE, ObjectWatchWorker, EXPECTED_COOKIE);
assert_ack_count(1);
assert_nack_count(0);
cl_assert_equal_i(EXPECTED_COOKIE, put_by... |
&layer_c);
cl_assert_equal_i(manager.state, RecognizerManagerState_RecognizersActive);
cl_assert_equal_i(recognizers[0]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[1]->state, RecognizerState_Possible);
cl_assert_equal_i(recognizers[3]->state, RecognizerState_Possible);
cl_assert_equal_i(r... | (NULL, 0, &s_recognizers_reset) | ;
cl_assert_equal_i(manager.state, RecognizerManagerState_WaitForTouchdown);
// Layer A's recognizer's gesture completes immediately. All recognizers receive the touch event
// because Layer A's recognizers receive the touch events last. All recognizers in the chain are
// reset
e.type = TouchEvent_Touchdown... |
/*
* 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, 72, bounds.size.w, 20) | );
text_layer_set_text(s_text_layer, "Press a button");
text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
layer_add_child(window_layer, text_layer_get_layer(s_text_layer));
}
static void prv_window_unload(Window *window) {
text_layer_destroy(s_text_layer);
}
static void prv_init(void) {
s_w... |
/*
* 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_equal_hex(crc, CRC32_RESIDUE) | ;
}
|
activity settings file from PFS and save to the local file system
char out_path[strlen(CLAR_FIXTURE_PATH) + strlen(ACTIVITY_FIXTURE_PATH) + strlen(filename) + 3];
sprintf(out_path, "%s/%s/%s", CLAR_FIXTURE_PATH, ACTIVITY_FIXTURE_PATH, filename);
// Open and read the settings file from PFS
int fd = pfs_open(A... | fake_system_task_callbacks_invoke_pending() | ;
// -----------------------------------
// Test that we receive step update events
fake_event_reset_count();
// Feed in 100 steps/minute over 1 minute. We should get some step update events
prv_feed_cannned_accel_data(1 * SECONDS_PER_MINUTE, 100, ActivitySleepStateAwake);
uint32_t event_count = fake_even... |
uration_a + 2 * MIN_FRAME_INTERVAL_MS + 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 2);
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), 0);
cl_assert_equal_i(prv_count_handle... | prv_create_test_animation() | ;
animation_set_duration(a, duration_a);
Animation *b = prv_create_test_animation();
animation_set_duration(b, duration_b);
Animation *inner_seq = animation_sequence_create(a, b, NULL);
animation_set_play_count(inner_seq, 0);
animation_set_handlers(inner_seq, handlers, inner_seq);
// Create the outer s... |
q(bitmap, GET_PBI_NAME(3)));
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(4)));
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(5)));
gbitmap_sequence_update_... | gbitmap_sequence_update_bitmap_by_elapsed(bitmap_sequence, bitmap, 12345 * 1000) | ;
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(5)));
#endif
}
// Tests APNG file with 8-bit color, 5 frames and loop = 1
// Tests gbitmap_sequence_update_bitmap_by_elapsed with 0 delay frames for 1, 4 and 5
// and 2 & 3 have delay 1000ms
// Result:
// - gbitmaps matches platform decoded APNG
void test_gbitmap_sequ... |
a modal is on top
e->task_mask |= 1 << PebbleTask_App;
modal_manager_handle_button_event(e);
return;
}
if (watchface_running) {
watchface_handle_button_event(e);
// suppress the button event from the app task
e->task_mask |= 1 << PebbleTask_App;
}
}
// This function should handle very b... | (&e->firmware_update) | ;
return;
case PEBBLE_ECOMPASS_SERVICE_EVENT:
#if CAPABILITY_HAS_MAGNETOMETER
ecompass_service_handle();
#endif
return;
case PEBBLE_SET_TIME_EVENT:
{
#ifndef RECOVERY_FW
PebbleSetTimeEvent *set_time_info = &e->set_time_info;
// The phone and watch time may be out of sync by ... |
ession_ref = sys_hrm_manager_app_subscribe(app_id, 1, expire_s, HRMFeature_BPM);
cl_assert(sys_hrm_manager_get_app_subscription(app_id) == session_ref);
prv_fake_send_new_data();
// We should get the BPM event
cl_assert_equal_i(s_event_count, 1);
cl_assert_equal_i(s_events_received[0].type, PEBBLE_HRM_EVENT... | cl_assert(prv_get_subscriber_state_from_app_id(PebbleTask_App, app_ids[i]) == NULL) | ;
}
cl_assert_equal_b(hrm_is_enabled(HRM), false);
}
void test_hrm_manager__feature_callbacks(void) {
const int num_refs = 2;
HRMSessionRef session_refs[num_refs];
AppInstallId app_id = 1;
for (int i = 0; i < num_refs; ++i, app_id++) {
const uint16_t expire_s = SECONDS_PER_MINUTE;
session_refs[i]... |
w_stroke_${BIT_DEPTH_NAME}__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
void inside_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_stroke_width(ctx, 10);
graphics_context_set_antialiased(ctx, false);
g... | (&ctx.dest_bitmap, "draw_stroke_across_nxny_origin_layer.${BIT_DEPTH_NAME}.pbi") | );
#endif
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, STROKE_WIDTH);
graphics_draw_line(&ctx, END_ON_ORIGIN_RECT, END_ON_ORIGIN_RECT);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_same_point_origin_layer.${BIT_DEPTH_NAME}.pbi"));
}
#define OFFSET_RECT_NO_CLIP GRec... |
;
}
void test_alarm__alarm_delete(void) {
AlarmId id1, id2, id3, id4, id5, id6, id7;
id1 = alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
id2 = alarm_create(&(AlarmInfo) { .hour = 4, .minute = 14, .kind = ALARM_KIND_EVERYDAY });
alarm_delete(id1);
prv_assert_alarm_config... | (alarm_kind, false /* all_caps */) | );
const AlarmKind pin_alarm_kind = (AlarmKind)attribute_get_uint8(pin_attr_list,
AttributeIdAlarmKind, 0);
cl_assert_equal_i(pin_alarm_kind, alarm_kind);
cl_assert_equal_i(s_last_timeline_item_added->action_group.num_actions, 1);
const Timeli... |
argc > 0 ? (jerry_get_number_value(argv[0]) - 0.5) * FIXED_S16_3_FACTOR : 0;
const double raw_y = argc > 1 ? (jerry_get_number_value(argv[1]) - 0.5) * FIXED_S16_3_FACTOR : 0;
if (raw_x < INT16_MIN || raw_x > INT16_MAX || raw_y < INT16_MIN || raw_x > INT16_MAX) {
return rocky_error_argument_invalid("Value out ... | prv_fill_points(points, points_num) | ;
cleanup:
task_free(points);
return rv;
}
JERRY_FUNCTION(prv_arc) {
GPointPrecise center;
Fixed_S16_3 radius;
double angle_1, angle_2;
ROCKY_ARGS_ASSIGN_OR_RETURN_ERROR(
ROCKY_ARG(center.x),
ROCKY_ARG(center.y),
ROCKY_ARG(radius),
ROCKY_ARG_ANGLE(angle_1),
ROCKY_ARG_ANGLE(angle_2));
... |
rror_dialog = &data->long_error_dialog;
expandable_dialog_init(long_error_dialog, "Error");
Dialog *dialog = expandable_dialog_get_dialog(long_error_dialog);
const GColor dialog_bg_color = PBL_IF_COLOR_ELSE(GColorLightGray, GColorWhite);
prv_init_dialog(data, dialog, text, resource_id, false, dialog_bg_color);
... | app_timer_register(DICTATION_TIMEOUT, prv_dictation_timeout_cb,
data) | ;
// Update UI
prv_set_mic_window_state(data, StateRecording);
break;
case VoiceStatusErrorConnectivity:
// Subsequent attempts are probably going to result in the same error. Let the user sort
// out the error and re-enter the dialog.
prv_show_connectivity_error_and_exit(data)... |
sert_equal_s(dstbuf, "zero1");
// Minimum digits output (negative digits, acts as zero)
snprintf(dstbuf, 256, "%.-3dzero%.-3d", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (non-zero digits outputting zero)
snprintf(dstbuf, 256, "%.1dzero%.1d", 0, 1);
cl_assert_equal_s(dstbuf, "0zer... | cl_assert_equal_s(dstbuf, "-16,-8464,-1698898192,-1698898192") | |
key_len == sizeof(BTBondingID)) {
// Skip pairing entries
return;
}
// Re-write non-pairing entries
void *key = kernel_zalloc_check(info->key_len);
info->get_key(old_file, key, info->key_len);
void *data = kernel_malloc_check(info->val_len);
info->get_val(old_file, data, info->val_len);
settin... | (file, &key[0], info->key_len) | ;
// prompt_send_response("Raw dump Key");
// PBL_HEXDUMP_D_PROMPT(LOG_LEVEL_DEBUG, (uint8_t *)&key, info->key_len);
uint8_t val[info->val_len];
memset(val, 0x0, info->val_len);
info->get_val(file, &val[0], info->val_len);
// prompt_send_response("Raw dump Value:");
// PBL_HEXDUMP_D_PROMPT(LOG_LEVEL_DEBU... |
ntext now if the animation got destroyed
cl_assert(animation_get_context(h) == NULL);
// Make sure no animations exist
cl_assert_equal_i(prv_count_animations(), 0);
#endif
}
// --------------------------------------------------------------------------------------
// Stopped handler that calls destroy
static vo... | cl_assert_equal_i(prv_count_animations(), 0) | ;
}
// --------------------------------------------------------------------------------------
// Test setting a play count of 0
void test_animation__basic_play_count_0(void) {
#ifdef TEST_INCLUDE_BASIC
const int duration_a = 300;
Animation *a = prv_create_test_animation();
animation_set_play_count(a, 0);
an... |
uint8_t s_tap_subscribers_count = 0;
AccelSamplingRate s_accel_sampling_rate;
static uint8_t s_accel_samples_per_update;
static TimerID s_timer_id = TIMER_INVALID_ID;
static bool s_temp_peek_mode = false;
static bool s_enabled = false;
// NOTE: All of our event service callbacks (add/remove subscriber, control) are ... | if (num_samples > ACCEL_MAX_SAMPLES_PER_UPDATE) {
num_samples = ACCEL_MAX_SAMPLES_PER_UPDATE;
} |
accel_set_num_samples(num_samples);
s_accel_samples_per_update = num_samples;
PBL_LOG(LOG_LEVEL_DEBUG, "setting accel rate:%d, num_samples:%"PRIu32, highest_rate, num_samples);
}
// Switch accelerometer into and out of low power mode. This function is
// idempotent; calling it multiple times in a row with the ... |
_RECT_NO_CLIP, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_origin_odd_clip")));
}
void test_graphics_draw_line___even_offset... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_even_offset_odd_clip"))) | ;
}
void test_graphics_draw_line___odd_offset_vertical_dotted(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Test odd and even cols draw appropriately
setup_test_aa_sw(&ctx, fb, OFFSET_RECT_ODD, OFFSET_RECT_ODD, false, 1);
graphics_draw_vertical_line_dotted(&ctx, GPoint(12, 6), 10);
graphi... |
G_READ)) == OP_FLAG_READ);
if ((!read_only) || (fd != E_DOES_NOT_EXIST)) {
PBL_LOG(LOG_LEVEL_ERROR, "Error opening file %d", fd);
// Remove file so next open will create a new one (notification storage trashed)
pfs_remove(FILENAME);
}
notification_storage_unlock();
}
return fd;
}
stat... | (*fd, 0, FSeekSet) | ;
prv_reclaim_space(size_needed - size_available, *fd);
}
pfs_seek(*fd, 0, FSeekSet);
int write_offset = 0;
// Iterate over notifications stored and write to new file
NotificationIterState iter_state = {
.fd = *fd,
};
Iterator iter;
iter_init(&iter, (IteratorCallback)&prv_iter_next, NULL, &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... | gpio_output_set(&BMA255_SCS_CONFIG, true) | ;
bma255_enable_spi_clock();
bma255_send_and_receive_byte(address);
}
//! Disables spi clock and sets SCS to end txn
void bma255_end_txn(void) {
bma255_disable_spi_clock();
gpio_output_set(&BMA255_SCS_CONFIG, false);
}
void bma255_burst_read(uint8_t address, uint8_t *data, size_t len) {
const uint8_t reg = ... |
.slices = {
{
.expiration_time = 1464734484, // (Tue, 31 May 2016 22:41:24 GMT)
.type = AppGlanceSliceType_IconAndSubtitle,
.icon_and_subtitle = {
.icon_resource_id = TIMELINE_RESOURCE_SCHEDULED_FLIGHT,
.template_string = "Glances baby!",
},
... | prv_insert_glances_for_app_selected_and_apps_above_and_below_with_glances_test() | ;
prv_render_launcher_menu_layer(LauncherMenuLayerTestApp_InteriorApp);
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
|
cky_api_graphics_color_parse(const char *color_value, GColor8 *parsed_color) {
return false;
}
bool rocky_api_graphics_color_from_value(jerry_value_t value, GColor *result) {
return false;
}
static Window s_app_window_stack_get_top_window;
Window *app_window_stack_get_top_window() {
return &s_app_window_stack_g... | {
jerry_cleanup();
rocky_runtime_context_deinit();
} |
fake_pbl_malloc_check_net_allocs();
}
static const RockyGlobalAPI *s_graphics_api[] = {
&GRAPHIC_APIS,
NULL,
};
#define PP(x, y) \
GPointPrecise((int16_t)(((x)) * FIXED_S16_3_FACTOR), \
(int16_t)(((y)) * FIXED_S16_3_FACTOR))
void test_rocky_api_graphics_path2d__invalid_coords(void) {
rock... |
log inputs to save some power
// SCLK
InputConfig sclk = { .gpio = bus->spi_sclk.gpio, .gpio_pin = bus->spi_sclk.gpio_pin };
gpio_analog_init(&sclk);
// MOSI
InputConfig mosi = { .gpio = bus->spi_mosi.gpio, .gpio_pin = bus->spi_mosi.gpio_pin };
gpio_analog_init(&mosi);
// MISO
if (is_bidirectional) {... | prv_is_bidrectional(slave) | );
// SCS
gpio_output_init(&slave->spi_scs, GPIO_OType_PP, slave->spi_bus->spi_sclk_speed);
gpio_output_set(&slave->spi_scs, false); // SCS not asserted (high)
// Set up an SPI
prv_spi_slave_deinit(slave);
prv_spi_slave_init(slave);
// Set up DMA
if (slave->rx_dma) {
dma_request_init(slave->rx_... |
turn prv_content_width() + PBL_IF_RECT_ELSE(prv_config()->horizontal_margin / 2, 0);
}
static GRect prv_artist_rect(void) {
const MusicAppSizeConfig *config = prv_config();
return GRect(config->horizontal_margin, config->artist_field.origin_y,
prv_text_layer_width(), config->artist_field.size_h);
}
... | app_timer_reschedule(data->volume_icon_timer, VOLUME_ICON_TIMEOUT_MS) | ;
} else {
data->volume_icon_timer = app_timer_register(VOLUME_ICON_TIMEOUT_MS,
prv_handle_volume_icon_timer, data);
}
prv_trigger_cassette_icon_switch(bitmap, true);
}
static void prv_change_volume(bool volume_is_up) {
if (!music_is_command_supported(MusicC... |
) {
// NOTE: THIS IS RUN WITHIN AN ISR
if (smartstrap_fsm_state_get() != SmartstrapStateReadDisabled) {
// we should no longer be sending
return false;
}
// handle escaped bytes first
if (s_send_info.sent_escape) {
s_send_info.sent_escape = false;
return prv_send_byte_and_check(s_send_info.es... | (&end_flag_mbuf, MBUF_FLAG_IS_FRAMING, true) | |
ds_notifications_received, 2);
cl_assert_equal_i(fake_kernel_services_notifications_ancs_notifications_count(), 1);
}
void test_ancs__attribute_at_end(void) {
prv_send_notification((uint8_t *)&memory_with_attribute_id_at_end.attribute_data);
cl_assert_equal_i(s_num_requested_notif_attributes, 1 );
cl_assert_e... | ancs_handle_ios9_or_newer_detected() | ;
prv_fake_receiving_ns_notification(sizeof(ns_notification), (uint8_t*) &ns_notification);
cl_assert_equal_i(fake_kernel_services_notifications_acted_upon_count(), 1);
}
void test_ancs__notification_parsing(void) {
// Test a recognized app with a duplicated title
// Run multiple times to make sure we're not c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.