mirror of
https://github.com/google/pebble.git
synced 2025-08-27 02:17:35 -04:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
236
tests/fw/apps/watch/kickstart/test_kickstart.c
Normal file
236
tests/fw/apps/watch/kickstart/test_kickstart.c
Normal file
|
@ -0,0 +1,236 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in 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 "apps/watch/kickstart/kickstart.h"
|
||||
#include "popups/timeline/peek.h"
|
||||
|
||||
#include "applib/ui/window_private.h"
|
||||
#include "fw/graphics/util.h"
|
||||
#include "util/size.h"
|
||||
|
||||
#include "clar.h"
|
||||
|
||||
extern void prv_window_load_handler(Window *window);
|
||||
extern void prv_window_unload_handler(Window *window);
|
||||
extern void prv_set_unobstructed_area_height(int16_t height);
|
||||
extern void prv_set_data(KickstartData *data, int32_t current_steps,
|
||||
int32_t typical_steps, int32_t daily_steps_avg, int32_t current_bpm);
|
||||
|
||||
// Fakes
|
||||
/////////////////////
|
||||
|
||||
#include "fake_pbl_std.h"
|
||||
#include "fake_spi_flash.h"
|
||||
#include "fixtures/load_test_resources.h"
|
||||
|
||||
static bool s_clock_is_24h_style = false;
|
||||
bool clock_is_24h_style(void) {
|
||||
return s_clock_is_24h_style;
|
||||
}
|
||||
|
||||
// Stubs
|
||||
/////////////////////
|
||||
|
||||
#include "stubs_analytics.h"
|
||||
#include "stubs_app.h"
|
||||
#include "stubs_app_install_manager.h"
|
||||
#include "stubs_app_timer.h"
|
||||
#include "stubs_app_window_stack.h"
|
||||
#include "stubs_bootbits.h"
|
||||
#include "stubs_click.h"
|
||||
#include "stubs_event_service_client.h"
|
||||
#include "stubs_health_service.h"
|
||||
#include "stubs_layer.h"
|
||||
#include "stubs_logging.h"
|
||||
#include "stubs_memory_layout.h"
|
||||
#include "stubs_mutex.h"
|
||||
#include "stubs_passert.h"
|
||||
#include "stubs_pbl_malloc.h"
|
||||
#include "stubs_pebble_process_info.h"
|
||||
#include "stubs_pebble_tasks.h"
|
||||
#include "stubs_process_manager.h"
|
||||
#include "stubs_prompt.h"
|
||||
#include "stubs_serial.h"
|
||||
#include "stubs_shell_prefs.h"
|
||||
#include "stubs_sleep.h"
|
||||
#include "stubs_syscalls.h"
|
||||
#include "stubs_task_watchdog.h"
|
||||
#include "stubs_text_layer_flow.h"
|
||||
#include "stubs_vibes.h"
|
||||
#include "stubs_window_manager.h"
|
||||
#include "stubs_window_stack.h"
|
||||
|
||||
void tick_timer_service_subscribe(TimeUnits tick_units, TickHandler handler) {}
|
||||
|
||||
void tick_timer_service_unsubscribe(void) {}
|
||||
|
||||
// Setup and Teardown
|
||||
////////////////////////////////////
|
||||
|
||||
static GContext s_ctx;
|
||||
static FrameBuffer s_fb;
|
||||
|
||||
static KickstartData s_data;
|
||||
|
||||
GContext *graphics_context_get_current_context(void) {
|
||||
return &s_ctx;
|
||||
}
|
||||
|
||||
void test_kickstart__initialize(void) {
|
||||
// Setup graphics context
|
||||
framebuffer_init(&s_fb, &(GSize) {DISP_COLS, DISP_ROWS});
|
||||
framebuffer_clear(&s_fb);
|
||||
graphics_context_init(&s_ctx, &s_fb, GContextInitializationMode_App);
|
||||
s_app_state_get_graphics_context = &s_ctx;
|
||||
|
||||
// Setup resources
|
||||
fake_spi_flash_init(0 /* offset */, 0x1000000 /* length */);
|
||||
pfs_init(false /* run filesystem check */);
|
||||
pfs_format(true /* write erase headers */);
|
||||
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
|
||||
false /* is_next */);
|
||||
resource_init();
|
||||
|
||||
// Reset data
|
||||
prv_set_data(&s_data, 0, 0, 0, 0);
|
||||
prv_set_unobstructed_area_height(0);
|
||||
s_clock_is_24h_style = false;
|
||||
|
||||
// Init window
|
||||
window_init(&s_data.window, WINDOW_NAME("Kickstart"));
|
||||
window_set_user_data(&s_data.window, &s_data);
|
||||
window_set_window_handlers(&s_data.window, &(WindowHandlers){
|
||||
.load = prv_window_load_handler,
|
||||
.unload = prv_window_unload_handler,
|
||||
});
|
||||
}
|
||||
|
||||
void test_kickstart__cleanup(void) {
|
||||
window_deinit(&s_data.window);
|
||||
}
|
||||
|
||||
// Tests
|
||||
//////////////////////
|
||||
|
||||
void test_kickstart__render_no_data(void) {
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_kickstart__render_obstructed_area(void) {
|
||||
#if !PBL_ROUND
|
||||
prv_set_unobstructed_area_height(TIMELINE_PEEK_HEIGHT);
|
||||
prv_set_data(&s_data, 5543, 6500, 8000, 0);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_kickstart__render_steps_above_typical(void) {
|
||||
prv_set_data(&s_data, 3528, 2500, 8000, 0);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_kickstart__render_steps_below_typical(void) {
|
||||
prv_set_data(&s_data, 5543, 6500, 8000, 0);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_kickstart__render_steps_above_daily_avg(void) {
|
||||
prv_set_data(&s_data, 10323, 7500, 8000, 0);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_kickstart__render_hr_bpm(void) {
|
||||
#if (PLATFORM_SILK || PLATFORM_ROBERT)
|
||||
prv_set_data(&s_data, 10323, 7500, 13000, 82);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_kickstart__render_hr_bpm_obstructed(void) {
|
||||
#if (PLATFORM_SILK || PLATFORM_ROBERT)
|
||||
prv_set_data(&s_data, 10323, 7500, 13000, 82);
|
||||
prv_set_unobstructed_area_height(TIMELINE_PEEK_HEIGHT);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_kickstart__render_steps_above_daily_avg_24h(void) {
|
||||
s_clock_is_24h_style = true;
|
||||
prv_set_data(&s_data, 10323, 7500, 8000, 0);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_kickstart__render_hr_bpm_24h(void) {
|
||||
#if (PLATFORM_SILK || PLATFORM_ROBERT)
|
||||
s_clock_is_24h_style = true;
|
||||
prv_set_data(&s_data, 10323, 7500, 13000, 82);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_kickstart__render_hr_bpm_obstructed_24h(void) {
|
||||
#if (PLATFORM_SILK || PLATFORM_ROBERT)
|
||||
s_clock_is_24h_style = true;
|
||||
prv_set_data(&s_data, 10323, 7500, 13000, 82);
|
||||
prv_set_unobstructed_area_height(TIMELINE_PEEK_HEIGHT);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_kickstart__render_PBL_43681(void) {
|
||||
prv_set_data(&s_data, 0, 1098, 8, 0);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_kickstart__render_PBL_43717(void) {
|
||||
prv_set_data(&s_data, 7, 0, 7, 0);
|
||||
|
||||
window_set_on_screen(&s_data.window, true, true);
|
||||
window_render(&s_data.window, &s_ctx);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
87
tests/fw/apps/watch/kickstart/wscript
Normal file
87
tests/fw/apps/watch/kickstart/wscript
Normal file
|
@ -0,0 +1,87 @@
|
|||
from waftools.pebble_test import clar
|
||||
|
||||
def build(ctx):
|
||||
rendering_sources = \
|
||||
" src/fw/applib/fonts/codepoint.c" \
|
||||
" src/fw/applib/graphics/${BITDEPTH}_bit/framebuffer.c" \
|
||||
" src/fw/applib/graphics/${BITDEPTH}_bit/bitblt_private.c" \
|
||||
" src/fw/applib/graphics/bitblt.c" \
|
||||
" src/fw/applib/graphics/framebuffer.c" \
|
||||
" src/fw/applib/graphics/gbitmap.c" \
|
||||
" src/fw/applib/graphics/gbitmap_png.c" \
|
||||
" src/fw/applib/graphics/gbitmap_sequence.c" \
|
||||
" src/fw/applib/graphics/gcolor_definitions.c" \
|
||||
" src/fw/applib/graphics/gdraw_command.c" \
|
||||
" src/fw/applib/graphics/gdraw_command_frame.c" \
|
||||
" src/fw/applib/graphics/gdraw_command_image.c" \
|
||||
" src/fw/applib/graphics/gdraw_command_list.c" \
|
||||
" src/fw/applib/graphics/gdraw_command_sequence.c" \
|
||||
" src/fw/applib/graphics/gpath.c" \
|
||||
" src/fw/applib/graphics/graphics.c" \
|
||||
" src/fw/applib/graphics/graphics_bitmap.c" \
|
||||
" src/fw/applib/graphics/graphics_circle.c" \
|
||||
" src/fw/applib/graphics/graphics_line.c" \
|
||||
" src/fw/applib/graphics/graphics_private.c" \
|
||||
" src/fw/applib/graphics/graphics_private_raw.c" \
|
||||
" src/fw/applib/graphics/gtransform.c" \
|
||||
" src/fw/applib/graphics/gtypes.c" \
|
||||
" src/fw/applib/graphics/perimeter.c" \
|
||||
" src/fw/applib/graphics/text_layout.c" \
|
||||
" src/fw/applib/graphics/text_render.c" \
|
||||
" src/fw/applib/graphics/text_resources.c" \
|
||||
" src/fw/applib/graphics/utf8.c" \
|
||||
" src/fw/applib/ui/status_bar_layer.c" \
|
||||
" src/fw/applib/ui/layer.c" \
|
||||
" src/fw/applib/vendor/tinflate/tinflate.c" \
|
||||
" src/fw/applib/vendor/uPNG/upng.c" \
|
||||
" src/fw/board/displays/display_spalding.c" \
|
||||
" src/fw/drivers/flash/flash_crc.c" \
|
||||
" src/fw/flash_region/filesystem_regions.c" \
|
||||
" src/fw/flash_region/flash_region.c" \
|
||||
" src/fw/resource/resource.c" \
|
||||
" src/fw/resource/resource_storage.c" \
|
||||
" src/fw/resource/resource_storage_builtin.c" \
|
||||
" src/fw/resource/resource_storage_file.c" \
|
||||
" src/fw/resource/resource_storage_flash.c" \
|
||||
" src/fw/services/normal/filesystem/app_file.c" \
|
||||
" src/fw/services/normal/filesystem/flash_translation.c" \
|
||||
" src/fw/services/normal/filesystem/pfs.c" \
|
||||
" src/fw/system/hexdump.c" \
|
||||
" src/fw/util/crc8.c" \
|
||||
" src/fw/util/legacy_checksum.c" \
|
||||
" tests/fakes/fake_applib_resource.c" \
|
||||
" tests/fakes/fake_display.c" \
|
||||
" tests/fakes/fake_gbitmap_get_data_row.c" \
|
||||
" tests/fakes/fake_rtc.c" \
|
||||
" tests/fakes/fake_spi_flash.c" \
|
||||
" tests/fixtures/resources/builtin_resources.auto.c" \
|
||||
" tests/fixtures/resources/pfs_resource_table.c" \
|
||||
" tests/stubs/stubs_animation.c" \
|
||||
" tests/stubs/stubs_system_theme.c"
|
||||
|
||||
kickstart_app_sources = \
|
||||
" src/fw/applib/graphics/gpath_builder.c" \
|
||||
" src/fw/applib/ui/animation_interpolate.c" \
|
||||
" src/fw/applib/ui/shadows.c" \
|
||||
" src/fw/applib/ui/text_layer.c" \
|
||||
" src/fw/applib/ui/window.c" \
|
||||
" src/fw/apps/system_apps/timeline/text_node.c" \
|
||||
" src/fw/services/normal/activity/health_util.c" \
|
||||
" src/fw/util/buffer.c" \
|
||||
" src/fw/util/stats.c" \
|
||||
" src/fw/util/time/mktime.c" \
|
||||
" src/fw/util/time/time.c" \
|
||||
" tests/fakes/fake_clock.c" \
|
||||
" tests/fakes/fake_fonts.c"
|
||||
|
||||
clar(ctx,
|
||||
sources_ant_glob = rendering_sources + \
|
||||
kickstart_app_sources + \
|
||||
" src/fw/apps/watch/kickstart/kickstart.c",
|
||||
test_sources_ant_glob = "test_kickstart.c",
|
||||
defines=ctx.env.test_image_defines + ["USE_DISPLAY_PERIMETER_ON_FONT_LAYOUT=1"],
|
||||
runtime_deps=ctx.env.test_pngs + ctx.env.test_pbis + ctx.env.test_pfos,
|
||||
override_includes=['dummy_board'],
|
||||
platforms=['snowy', 'spalding', 'silk', 'robert'])
|
||||
|
||||
# vim:filetype=python
|
Loading…
Add table
Add a link
Reference in a new issue