mirror of
https://github.com/google/pebble
synced 2026-10-18 01:04:12 +02:00
Import of the watch repository from Pebble
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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/system_apps/health/health_activity_detail_card.h"
|
||||
#include "apps/system_apps/health/health_detail_card.h"
|
||||
#include "apps/system_apps/health/health_data.h"
|
||||
#include "apps/system_apps/health/health_data_private.h"
|
||||
#include "apps/system_apps/health/health_progress.h"
|
||||
|
||||
#include "test_health_app_includes.h"
|
||||
|
||||
// Setup and Teardown
|
||||
////////////////////////////////////
|
||||
|
||||
static GContext s_ctx;
|
||||
static FrameBuffer s_fb;
|
||||
|
||||
GContext *graphics_context_get_current_context(void) {
|
||||
return &s_ctx;
|
||||
}
|
||||
|
||||
void test_health_activity_detail_card__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();
|
||||
|
||||
// Setup content indicator
|
||||
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
|
||||
content_indicator_init_buffer(buffer);
|
||||
}
|
||||
|
||||
void test_health_activity_detail_card__cleanup(void) {
|
||||
}
|
||||
|
||||
// Helpers
|
||||
//////////////////////
|
||||
|
||||
static Window* prv_create_card_and_render(HealthData *health_data) {
|
||||
Window *window = health_activity_detail_card_create(health_data);
|
||||
window_set_on_screen(window, true, true);
|
||||
window_render(window, &s_ctx);
|
||||
return window;
|
||||
}
|
||||
|
||||
// Tests
|
||||
//////////////////////
|
||||
|
||||
void test_health_activity_detail_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_detail_card__render_current_calories_and_distance(void) {
|
||||
HealthData health_data = {
|
||||
.current_calories = 123,
|
||||
.current_distance_meters = 4000,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_detail_card__render_no_calories(void) {
|
||||
HealthData health_data = {
|
||||
.current_calories = 0,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_detail_card__render_no_distance(void) {
|
||||
HealthData health_data = {
|
||||
.current_distance_meters = 0,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_detail_card__render_step_data(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = {600, 900, 700, 1200, 1400, 1300, 1000},
|
||||
.monthly_step_average = 1000,
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&health_data);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 3), MenuRowAlignCenter, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_detail_card__render_day_label_no_steps(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = {600, 0, 700},
|
||||
.monthly_step_average = 1000,
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&health_data);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 2), MenuRowAlignCenter, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
* 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/system_apps/health/health_data.h"
|
||||
#include "apps/system_apps/health/health_data_private.h"
|
||||
#include "apps/system_apps/health/health_activity_summary_card.h"
|
||||
#include "apps/system_apps/health/health_activity_detail_card.h"
|
||||
#include "apps/system_apps/health/health_detail_card.h"
|
||||
|
||||
#include "test_health_app_includes.h"
|
||||
|
||||
// Setup and Teardown
|
||||
////////////////////////////////////
|
||||
|
||||
static GContext s_ctx;
|
||||
static FrameBuffer s_fb;
|
||||
|
||||
GContext *graphics_context_get_current_context(void) {
|
||||
return &s_ctx;
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__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();
|
||||
|
||||
// Setup content indicator
|
||||
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
|
||||
content_indicator_init_buffer(buffer);
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__cleanup(void) {
|
||||
}
|
||||
|
||||
// Helpers
|
||||
//////////////////////
|
||||
|
||||
static void prv_create_card_and_render(HealthData *health_data) {
|
||||
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_color(&window, health_activity_summary_card_get_bg_color(card_layer));
|
||||
window_set_on_screen(&window, true, true);
|
||||
window_render(&window, &s_ctx);
|
||||
}
|
||||
|
||||
// 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 = 0,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 750,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_behind_typical1(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 170,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 340,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_behind_typical2(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 320,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 340,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_behind_typical3(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 460,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 555,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_behind_typical4(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 699,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 840,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_behind_typical5(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 837,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 914,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_equals_typical(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 837,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 837,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_above_typical1(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 340,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 170,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_above_typical2(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 400,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 379,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_above_typical3(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 780,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 480,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_above_typical4(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 866,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 700,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_above_typical5(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = 970,
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 900,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_activity_summary_card__render_current_above_expected(void) {
|
||||
HealthData health_data = {
|
||||
.step_data = {2000},
|
||||
.step_averages = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 50}, // 1000
|
||||
.current_step_average = 800,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 "applib/ui/window_private.h"
|
||||
#include "util/size.h"
|
||||
|
||||
#include "clar.h"
|
||||
|
||||
// Fakes
|
||||
/////////////////////
|
||||
|
||||
#include "fake_content_indicator.h"
|
||||
#include "fake_rtc.h"
|
||||
#include "fake_spi_flash.h"
|
||||
#include "fixtures/load_test_resources.h"
|
||||
|
||||
// Stubs
|
||||
/////////////////////
|
||||
|
||||
#include "stubs_activity.h"
|
||||
#include "stubs_analytics.h"
|
||||
#include "stubs_animation_timing.h"
|
||||
#include "stubs_app_install_manager.h"
|
||||
#include "stubs_app_launch_reason.h"
|
||||
#include "stubs_app_timer.h"
|
||||
#include "stubs_app_window_stack.h"
|
||||
#include "stubs_bootbits.h"
|
||||
#include "stubs_click.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_prompt.h"
|
||||
#include "stubs_serial.h"
|
||||
#include "stubs_shell_prefs.h"
|
||||
#include "stubs_sleep.h"
|
||||
#include "stubs_status_bar_layer.h"
|
||||
#include "stubs_syscalls.h"
|
||||
#include "stubs_task_watchdog.h"
|
||||
#include "stubs_window_manager.h"
|
||||
#include "stubs_window_stack.h"
|
||||
|
||||
// Helper Functions
|
||||
/////////////////////
|
||||
|
||||
#include "fw/graphics/util.h"
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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/system_apps/health/health_card_view.h"
|
||||
#include "apps/system_apps/health/health_data.h"
|
||||
#include "apps/system_apps/health/health_data_private.h"
|
||||
#include "apps/system_apps/health/health_detail_card.h"
|
||||
#include "apps/system_apps/health/health_activity_summary_card.h"
|
||||
#include "apps/system_apps/health/health_activity_detail_card.h"
|
||||
#include "apps/system_apps/health/health_hr_summary_card.h"
|
||||
#include "apps/system_apps/health/health_sleep_summary_card.h"
|
||||
#include "apps/system_apps/health/health_sleep_detail_card.h"
|
||||
|
||||
#include "test_health_app_includes.h"
|
||||
|
||||
// Fakes
|
||||
////////////////////////////////////
|
||||
|
||||
void clock_get_until_time_without_fulltime(char *buffer, int buf_size, time_t timestamp,
|
||||
int max_relative_hrs) {
|
||||
snprintf(buffer, buf_size, "5 MIN AGO");
|
||||
}
|
||||
|
||||
// Setup and Teardown
|
||||
////////////////////////////////////
|
||||
|
||||
static GContext s_ctx;
|
||||
static FrameBuffer s_fb;
|
||||
|
||||
GContext *graphics_context_get_current_context(void) {
|
||||
return &s_ctx;
|
||||
}
|
||||
|
||||
void test_health_card_view__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();
|
||||
|
||||
// Setup content indicator
|
||||
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
|
||||
content_indicator_init_buffer(buffer);
|
||||
}
|
||||
|
||||
void test_health_card_view__cleanup(void) {
|
||||
}
|
||||
|
||||
// Helpers
|
||||
//////////////////////
|
||||
|
||||
static Window* prv_create_card_and_render(HealthData *health_data) {
|
||||
Window *window = (Window *)health_card_view_create(health_data);
|
||||
window_set_on_screen(window, true, true);
|
||||
window_render(window, &s_ctx);
|
||||
return window;
|
||||
}
|
||||
|
||||
// Tests
|
||||
//////////////////////
|
||||
|
||||
void test_health_card_view__render_indicators(void) {
|
||||
prv_create_card_and_render(&(HealthData) {});
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* 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/system_apps/health/health_detail_card.h"
|
||||
#include "apps/system_apps/health/health_progress.h"
|
||||
|
||||
#include "test_health_app_includes.h"
|
||||
|
||||
#define BG_COLOR PBL_IF_COLOR_ELSE(GColorBlueMoon, GColorWhite)
|
||||
#define FILL_COLOR PBL_IF_COLOR_ELSE(GColorKellyGreen, GColorDarkGray)
|
||||
#define TODAY_FILL_COLOR PBL_IF_COLOR_ELSE(GColorMediumAquamarine, GColorDarkGray)
|
||||
|
||||
#define DEFAULT_ZONES { \
|
||||
{ .label = "Today", .progress = 700, .fill_color = TODAY_FILL_COLOR, .hide_typical = true }, \
|
||||
{ .label = "Wed", .progress = 1100, .fill_color = FILL_COLOR }, \
|
||||
{ .label = "Tue", .progress = 400, .fill_color = FILL_COLOR }, \
|
||||
{ .label = "Mon", .progress = 1300, .fill_color = FILL_COLOR }, \
|
||||
{ .label = "Sun", .progress = 800, .fill_color = FILL_COLOR }, \
|
||||
{ .label = "Sat", .progress = 700, .fill_color = FILL_COLOR }, \
|
||||
{ .label = "Fri", .progress = 1200, .fill_color = FILL_COLOR }, \
|
||||
}
|
||||
|
||||
static HealthDetailZone s_zones[] = DEFAULT_ZONES;
|
||||
|
||||
|
||||
// Setup and Teardown
|
||||
////////////////////////////////////
|
||||
|
||||
static GContext s_ctx;
|
||||
static FrameBuffer s_fb;
|
||||
|
||||
GContext *graphics_context_get_current_context(void) {
|
||||
return &s_ctx;
|
||||
}
|
||||
|
||||
void test_health_detail_card__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();
|
||||
|
||||
// Setup content indicator
|
||||
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
|
||||
content_indicator_init_buffer(buffer);
|
||||
}
|
||||
|
||||
void test_health_detail_card__cleanup(void) {
|
||||
}
|
||||
|
||||
// Helpers
|
||||
//////////////////////
|
||||
|
||||
static Window* prv_create_card_and_render(HealthDetailCardConfig *config) {
|
||||
Window *window = (Window *)health_detail_card_create(config);
|
||||
window_set_on_screen(window, true, true);
|
||||
window_render(window, &s_ctx);
|
||||
return window;
|
||||
}
|
||||
|
||||
// Tests
|
||||
//////////////////////
|
||||
|
||||
void test_health_detail_card__render_no_data(void) {
|
||||
prv_create_card_and_render(&(HealthDetailCardConfig) {});
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_detail_card__render_one_heading(void) {
|
||||
HealthDetailCardConfig config = {
|
||||
.num_headings = 1,
|
||||
.headings = &(HealthDetailHeading) {
|
||||
.primary_label = "LABEL1",
|
||||
.primary_value = "value1",
|
||||
.fill_color = GColorWhite,
|
||||
#if PBL_BW
|
||||
.outline_color = GColorBlack,
|
||||
#endif
|
||||
},
|
||||
.bg_color = BG_COLOR,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&config);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_detail_card__render_two_headings(void) {
|
||||
HealthDetailCardConfig config = {
|
||||
.num_headings = 1,
|
||||
.headings = &(HealthDetailHeading) {
|
||||
.primary_label = "LABEL1",
|
||||
.primary_value = "value1",
|
||||
.secondary_label = "LABEL2",
|
||||
.secondary_value = "value2",
|
||||
.fill_color = GColorWhite,
|
||||
#if PBL_BW
|
||||
.outline_color = GColorBlack,
|
||||
#endif
|
||||
},
|
||||
.bg_color = BG_COLOR,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&config);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_detail_card__render_subtitle_text(void) {
|
||||
HealthDetailCardConfig config = {
|
||||
.num_headings = 1,
|
||||
.headings = &(HealthDetailHeading) {
|
||||
.primary_label = "LABEL1",
|
||||
.primary_value = "value1",
|
||||
.secondary_label = "LABEL2",
|
||||
.secondary_value = "value2",
|
||||
.fill_color = GColorWhite,
|
||||
#if PBL_BW
|
||||
.outline_color = GColorBlack,
|
||||
#endif
|
||||
},
|
||||
.num_subtitles = 1,
|
||||
.subtitles = &(HealthDetailSubtitle) {
|
||||
.label = "30 DAY AVG",
|
||||
.fill_color = PBL_IF_COLOR_ELSE(GColorYellow, GColorBlack),
|
||||
},
|
||||
.bg_color = BG_COLOR,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&config);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_detail_card__render_no_subtitle(void) {
|
||||
HealthDetailCardConfig config = {
|
||||
.num_headings = 1,
|
||||
.headings = &(HealthDetailHeading) {
|
||||
.primary_label = "LABEL1",
|
||||
.primary_value = "value1",
|
||||
.fill_color = GColorWhite,
|
||||
#if PBL_BW
|
||||
.outline_color = GColorBlack,
|
||||
#endif
|
||||
},
|
||||
.bg_color = BG_COLOR,
|
||||
.daily_avg = 900,
|
||||
.weekly_max = 1300,
|
||||
.num_zones = ARRAY_LENGTH(s_zones),
|
||||
.zones = s_zones,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&config);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_detail_card__render_zones(void) {
|
||||
HealthDetailCardConfig config = {
|
||||
.num_headings = 1,
|
||||
.headings = &(HealthDetailHeading) {
|
||||
.primary_label = "LABEL1",
|
||||
.primary_value = "value1",
|
||||
.secondary_label = "LABEL2",
|
||||
.secondary_value = "value2",
|
||||
.fill_color = GColorWhite,
|
||||
#if PBL_BW
|
||||
.outline_color = GColorBlack,
|
||||
#endif
|
||||
},
|
||||
.num_subtitles = 1,
|
||||
.subtitles = &(HealthDetailSubtitle) {
|
||||
.label = "30 DAY AVG",
|
||||
.fill_color = PBL_IF_COLOR_ELSE(GColorYellow, GColorBlack),
|
||||
},
|
||||
.bg_color = BG_COLOR,
|
||||
.daily_avg = 900,
|
||||
.weekly_max = 1300,
|
||||
.num_zones = ARRAY_LENGTH(s_zones),
|
||||
.zones = s_zones,
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&config);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 3), MenuRowAlignCenter, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_detail_card__render_bg_and_zone_colors(void) {
|
||||
HealthDetailCardConfig config = {
|
||||
.num_headings = 1,
|
||||
.headings = &(HealthDetailHeading) {
|
||||
.primary_label = "LABEL1",
|
||||
.primary_value = "value1",
|
||||
.fill_color = GColorWhite,
|
||||
#if PBL_BW
|
||||
.outline_color = GColorBlack,
|
||||
#endif
|
||||
},
|
||||
.num_subtitles = 1,
|
||||
.subtitles = &(HealthDetailSubtitle) {
|
||||
.label = "30 DAY AVG",
|
||||
.fill_color = PBL_IF_COLOR_ELSE(GColorYellow, GColorBlack),
|
||||
},
|
||||
.bg_color = BG_COLOR,
|
||||
.daily_avg = 900,
|
||||
.weekly_max = 1300,
|
||||
.num_zones = ARRAY_LENGTH(s_zones),
|
||||
.zones = s_zones,
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&config);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 2), MenuRowAlignCenter, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_detail_card__render_crown(void) {
|
||||
HealthDetailZone zones[] = DEFAULT_ZONES;
|
||||
zones[1].show_crown = true;
|
||||
|
||||
HealthDetailCardConfig config = {
|
||||
.num_headings = 1,
|
||||
.headings = &(HealthDetailHeading) {
|
||||
.primary_label = "LABEL1",
|
||||
.primary_value = "value1",
|
||||
.fill_color = GColorWhite,
|
||||
#if PBL_BW
|
||||
.outline_color = GColorBlack,
|
||||
#endif
|
||||
},
|
||||
.num_subtitles = 1,
|
||||
.subtitles = &(HealthDetailSubtitle) {
|
||||
.label = "30 DAY AVG",
|
||||
.fill_color = PBL_IF_COLOR_ELSE(GColorYellow, GColorBlack),
|
||||
},
|
||||
.bg_color = BG_COLOR,
|
||||
.daily_avg = 900,
|
||||
.weekly_max = 1300,
|
||||
.num_zones = ARRAY_LENGTH(zones),
|
||||
.zones = zones,
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&config);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 2), MenuRowAlignCenter, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_detail_card__render_zone_hide_typical(void) {
|
||||
HealthDetailCardConfig config = {
|
||||
.num_headings = 1,
|
||||
.headings = &(HealthDetailHeading) {
|
||||
.primary_label = "LABEL1",
|
||||
.primary_value = "value1",
|
||||
.fill_color = GColorWhite,
|
||||
#if PBL_BW
|
||||
.outline_color = GColorBlack,
|
||||
#endif
|
||||
},
|
||||
.bg_color = BG_COLOR,
|
||||
.daily_avg = 900,
|
||||
.weekly_max = 1300,
|
||||
.num_zones = ARRAY_LENGTH(s_zones),
|
||||
.zones = s_zones,
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&config);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 1), MenuRowAlignCenter, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_detail_card__scroll_down(void) {
|
||||
HealthDetailCardConfig config = {
|
||||
.num_headings = 1,
|
||||
.headings = &(HealthDetailHeading) {
|
||||
.primary_label = "LABEL1",
|
||||
.primary_value = "value1",
|
||||
.fill_color = GColorWhite,
|
||||
#if PBL_BW
|
||||
.outline_color = GColorBlack,
|
||||
#endif
|
||||
},
|
||||
.bg_color = BG_COLOR,
|
||||
.daily_avg = 900,
|
||||
.weekly_max = 1300,
|
||||
.num_zones = ARRAY_LENGTH(s_zones),
|
||||
.zones = s_zones,
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&config);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 7), MenuRowAlignCenter, false);
|
||||
#else
|
||||
GPoint offset = scroll_layer_get_content_offset(&card->scroll_layer);
|
||||
offset.y -= scroll_layer_get_content_size(&card->scroll_layer).h;
|
||||
|
||||
scroll_layer_set_content_offset(&card->scroll_layer, offset, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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/system_apps/health/health_hr_detail_card.h"
|
||||
#include "apps/system_apps/health/health_detail_card.h"
|
||||
#include "apps/system_apps/health/health_data.h"
|
||||
#include "apps/system_apps/health/health_data_private.h"
|
||||
|
||||
#include "test_health_app_includes.h"
|
||||
|
||||
// Setup and Teardown
|
||||
////////////////////////////////////
|
||||
|
||||
static GContext s_ctx;
|
||||
static FrameBuffer s_fb;
|
||||
|
||||
GContext *graphics_context_get_current_context(void) {
|
||||
return &s_ctx;
|
||||
}
|
||||
|
||||
void test_health_hr_detail_card__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();
|
||||
|
||||
// Setup content indicator
|
||||
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
|
||||
content_indicator_init_buffer(buffer);
|
||||
}
|
||||
|
||||
void test_health_hr_detail_card__cleanup(void) {
|
||||
}
|
||||
|
||||
// Helpers
|
||||
//////////////////////
|
||||
|
||||
static Window* prv_create_card_and_render(HealthData *health_data) {
|
||||
Window *window = (Window *)health_hr_detail_card_create(health_data);
|
||||
window_set_on_screen(window, true, true);
|
||||
window_render(window, &s_ctx);
|
||||
return window;
|
||||
}
|
||||
|
||||
// Tests
|
||||
//////////////////////
|
||||
|
||||
void test_health_hr_detail_card__render_no_data(void) {
|
||||
prv_create_card_and_render(&(HealthData) {});
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_hr_detail_card__render_zones(void) {
|
||||
HealthData health_data = {
|
||||
.hr_zone1_minutes = 21,
|
||||
.hr_zone2_minutes = 13,
|
||||
.hr_zone3_minutes = 6,
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&health_data);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 2), MenuRowAlignCenter, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_hr_detail_card__render_zones2(void) {
|
||||
HealthData health_data = {
|
||||
.hr_zone1_minutes = 30,
|
||||
.hr_zone2_minutes = 35,
|
||||
.hr_zone3_minutes = 40,
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&health_data);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 2), MenuRowAlignCenter, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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/system_apps/health/health_data.h"
|
||||
#include "apps/system_apps/health/health_data_private.h"
|
||||
#include "apps/system_apps/health/health_hr_summary_card.h"
|
||||
#include "apps/system_apps/health/health_hr_detail_card.h"
|
||||
#include "apps/system_apps/health/health_detail_card.h"
|
||||
|
||||
#include "test_health_app_includes.h"
|
||||
|
||||
// Fakes
|
||||
////////////////////////////////////
|
||||
|
||||
void clock_get_until_time_without_fulltime(char *buffer, int buf_size, time_t timestamp,
|
||||
int max_relative_hrs) {
|
||||
snprintf(buffer, buf_size, "5 MIN AGO");
|
||||
}
|
||||
|
||||
// Setup and Teardown
|
||||
////////////////////////////////////
|
||||
|
||||
static GContext s_ctx;
|
||||
static FrameBuffer s_fb;
|
||||
|
||||
GContext *graphics_context_get_current_context(void) {
|
||||
return &s_ctx;
|
||||
}
|
||||
|
||||
void test_health_hr_summary_card__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();
|
||||
|
||||
// Setup content indicator
|
||||
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
|
||||
content_indicator_init_buffer(buffer);
|
||||
}
|
||||
|
||||
void test_health_hr_summary_card__cleanup(void) {
|
||||
}
|
||||
|
||||
// Helpers
|
||||
//////////////////////
|
||||
|
||||
static void prv_create_card_and_render(HealthData *health_data) {
|
||||
Window window;
|
||||
window_init(&window, WINDOW_NAME("Health"));
|
||||
Layer *window_layer = window_get_root_layer(&window);
|
||||
Layer *card_layer = health_hr_summary_card_create(health_data);
|
||||
layer_set_frame(card_layer, &window_layer->bounds);
|
||||
layer_add_child(window_layer, card_layer);
|
||||
window_set_background_color(&window, health_hr_summary_card_get_bg_color(card_layer));
|
||||
window_set_on_screen(&window, true, true);
|
||||
window_render(&window, &s_ctx);
|
||||
}
|
||||
|
||||
// Tests
|
||||
//////////////////////
|
||||
|
||||
void test_health_hr_summary_card__render_no_data(void) {
|
||||
prv_create_card_and_render(&(HealthData) {});
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_hr_summary_card__render_current_bpm(void) {
|
||||
HealthData health_data = {
|
||||
.current_hr_bpm = 110,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_hr_summary_card__render_timestamp(void) {
|
||||
rtc_set_time(SECONDS_PER_DAY + (SECONDS_PER_HOUR * 12));
|
||||
|
||||
HealthData health_data = {
|
||||
.current_hr_bpm = 110,
|
||||
.hr_last_updated = rtc_get_time() - (SECONDS_PER_MINUTE * 5),
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* 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/system_apps/health/health_sleep_detail_card.h"
|
||||
#include "apps/system_apps/health/health_detail_card.h"
|
||||
#include "apps/system_apps/health/health_data.h"
|
||||
#include "apps/system_apps/health/health_data_private.h"
|
||||
|
||||
#include "test_health_app_includes.h"
|
||||
|
||||
// Setup and Teardown
|
||||
////////////////////////////////////
|
||||
|
||||
static GContext s_ctx;
|
||||
static FrameBuffer s_fb;
|
||||
|
||||
GContext *graphics_context_get_current_context(void) {
|
||||
return &s_ctx;
|
||||
}
|
||||
|
||||
void test_health_sleep_detail_card__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();
|
||||
|
||||
// Setup content indicator
|
||||
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
|
||||
content_indicator_init_buffer(buffer);
|
||||
}
|
||||
|
||||
void test_health_sleep_detail_card__cleanup(void) {
|
||||
}
|
||||
|
||||
// Helpers
|
||||
//////////////////////
|
||||
|
||||
// static void prv_create_card_and_render(HealthData *health_data) {
|
||||
// Window *window = health_sleep_detail_card_create(health_data);
|
||||
// window_set_on_screen(window, true, true);
|
||||
// window_render(window, &s_ctx);
|
||||
// }
|
||||
|
||||
static Window* prv_create_card_and_render(HealthData *health_data) {
|
||||
Window *window = (Window *)health_sleep_detail_card_create(health_data);
|
||||
window_set_on_screen(window, true, true);
|
||||
window_render(window, &s_ctx);
|
||||
return window;
|
||||
}
|
||||
|
||||
// Tests
|
||||
//////////////////////
|
||||
|
||||
void test_health_sleep_detail_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_sleep_detail_card__render_sleep_session(void) {
|
||||
HealthData health_data = {
|
||||
.sleep_start = (23 * SECONDS_PER_HOUR) + (3 * SECONDS_PER_MINUTE),
|
||||
.sleep_end = (7 * SECONDS_PER_HOUR) + (45 * SECONDS_PER_MINUTE),
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_sleep_detail_card__render_sleep_session_same_start_end_time(void) {
|
||||
HealthData health_data = {
|
||||
.sleep_start = (16 * SECONDS_PER_HOUR),
|
||||
.sleep_end = (16 * SECONDS_PER_HOUR),
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_sleep_detail_card__render_30_day_avg(void) {
|
||||
HealthData health_data = {
|
||||
.monthly_sleep_average = (8 * SECONDS_PER_HOUR) + (17 * SECONDS_PER_MINUTE),
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_sleep_detail_card__render_deep_sleep(void) {
|
||||
HealthData health_data = {
|
||||
.deep_sleep = (3 * SECONDS_PER_HOUR) + (23 * SECONDS_PER_MINUTE),
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_sleep_detail_card__render_sleep_data_1(void) {
|
||||
HealthData health_data = {
|
||||
.sleep_data[0] = (7 * SECONDS_PER_HOUR) + (11 * SECONDS_PER_MINUTE),
|
||||
.sleep_data[1] = (6 * SECONDS_PER_HOUR) + (52 * SECONDS_PER_MINUTE),
|
||||
.sleep_data[2] = (7 * SECONDS_PER_HOUR) + (13 * SECONDS_PER_MINUTE),
|
||||
.sleep_data[3] = (9 * SECONDS_PER_HOUR) + (21 * SECONDS_PER_MINUTE),
|
||||
.sleep_data[4] = (9 * SECONDS_PER_HOUR) + (18 * SECONDS_PER_MINUTE),
|
||||
.monthly_sleep_average = (8 * SECONDS_PER_HOUR) + (17 * SECONDS_PER_MINUTE),
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&health_data);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 1), MenuRowAlignCenter, false);
|
||||
#else
|
||||
GPoint offset = scroll_layer_get_content_offset(&card->scroll_layer);
|
||||
|
||||
// scroll past sleep session, deep sleep and avg
|
||||
offset.y -= 114;
|
||||
|
||||
scroll_layer_set_content_offset(&card->scroll_layer, offset, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_sleep_detail_card__render_sleep_data_2(void) {
|
||||
HealthData health_data = {
|
||||
.sleep_data[0] = (7 * SECONDS_PER_HOUR) + (14 * SECONDS_PER_MINUTE),
|
||||
.sleep_data[1] = (4 * SECONDS_PER_HOUR) + (59 * SECONDS_PER_MINUTE),
|
||||
.sleep_data[2] = (8 * SECONDS_PER_HOUR) + (17 * SECONDS_PER_MINUTE),
|
||||
.sleep_data[3] = (5 * SECONDS_PER_HOUR) + (34 * SECONDS_PER_MINUTE),
|
||||
.sleep_data[4] = (7 * SECONDS_PER_HOUR) + (12 * SECONDS_PER_MINUTE),
|
||||
.sleep_data[5] = (8 * SECONDS_PER_HOUR) + (12 * SECONDS_PER_MINUTE),
|
||||
.sleep_data[6] = (10 * SECONDS_PER_HOUR) + (11 * SECONDS_PER_MINUTE),
|
||||
.monthly_sleep_average = (8 * SECONDS_PER_HOUR) + (36 * SECONDS_PER_MINUTE),
|
||||
};
|
||||
|
||||
HealthDetailCard *card = (HealthDetailCard *)prv_create_card_and_render(&health_data);
|
||||
|
||||
#if PBL_ROUND
|
||||
menu_layer_set_selected_index(&card->menu_layer, MenuIndex(0, 7), MenuRowAlignCenter, false);
|
||||
#else
|
||||
GPoint offset = scroll_layer_get_content_offset(&card->scroll_layer);
|
||||
offset.y -= scroll_layer_get_content_size(&card->scroll_layer).h;
|
||||
|
||||
scroll_layer_set_content_offset(&card->scroll_layer, offset, false);
|
||||
#endif
|
||||
|
||||
window_render(&card->window, &s_ctx);
|
||||
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* 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/system_apps/health/health_data.h"
|
||||
#include "apps/system_apps/health/health_data_private.h"
|
||||
#include "apps/system_apps/health/health_sleep_summary_card.h"
|
||||
|
||||
#include "test_health_app_includes.h"
|
||||
|
||||
// Setup and Teardown
|
||||
////////////////////////////////////
|
||||
|
||||
static GContext s_ctx;
|
||||
static FrameBuffer s_fb;
|
||||
|
||||
const int s_now_utc = 1467763200; // July 6, 2016
|
||||
|
||||
GContext *graphics_context_get_current_context(void) {
|
||||
return &s_ctx;
|
||||
}
|
||||
|
||||
void test_health_sleep_summary_card__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();
|
||||
|
||||
// Setup content indicator
|
||||
ContentIndicatorsBuffer *buffer = content_indicator_get_current_buffer();
|
||||
content_indicator_init_buffer(buffer);
|
||||
}
|
||||
|
||||
void test_health_sleep_summary_card__cleanup(void) {
|
||||
}
|
||||
|
||||
// Helpers
|
||||
//////////////////////
|
||||
|
||||
static void prv_create_card_and_render(HealthData *health_data) {
|
||||
Window window;
|
||||
window_init(&window, WINDOW_NAME("Health"));
|
||||
Layer *window_layer = window_get_root_layer(&window);
|
||||
Layer *card_layer = health_sleep_summary_card_create(health_data);
|
||||
layer_set_frame(card_layer, &window_layer->bounds);
|
||||
layer_add_child(window_layer, card_layer);
|
||||
window_set_background_color(&window, health_sleep_summary_card_get_bg_color(card_layer));
|
||||
window_set_on_screen(&window, true, true);
|
||||
window_render(&window, &s_ctx);
|
||||
}
|
||||
|
||||
// Tests
|
||||
//////////////////////
|
||||
|
||||
void test_health_sleep_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_sleep_summary_card__render_no_typical(void) {
|
||||
HealthData health_data = {
|
||||
.monthly_sleep_average = (9 * SECONDS_PER_HOUR),
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_sleep_summary_card__render_no_sleep_last_night(void) {
|
||||
HealthData health_data = {
|
||||
// Used for text
|
||||
.typical_sleep = (10 * SECONDS_PER_HOUR),
|
||||
.monthly_sleep_average = (300 * SECONDS_PER_HOUR),
|
||||
|
||||
// Used for typical
|
||||
.typical_sleep_start = -4 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_end = 7 * SECONDS_PER_HOUR,
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_sleep_summary_card__render_sleep_late_start_early_end1(void) {
|
||||
const time_t start_of_today = time_util_get_midnight_of(s_now_utc);
|
||||
|
||||
HealthData health_data = {
|
||||
// Used for text
|
||||
.sleep_data[0] = (8 * SECONDS_PER_HOUR) + (12 * SECONDS_PER_MINUTE),
|
||||
.typical_sleep = (10 * SECONDS_PER_HOUR),
|
||||
.monthly_sleep_average = (300 * SECONDS_PER_HOUR),
|
||||
|
||||
// Used for typical
|
||||
.sleep_start = -3 * SECONDS_PER_HOUR,
|
||||
.sleep_end = 5 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_start = -4 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_end = 7 * SECONDS_PER_HOUR,
|
||||
|
||||
// The sleep ring are filled by sleep sessions
|
||||
.num_activity_sessions = 3,
|
||||
.activity_sessions[0] = {
|
||||
.start_utc = start_of_today - (3 * SECONDS_PER_HOUR), // 9pm
|
||||
.length_min = (3 * MINUTES_PER_HOUR),
|
||||
.type = ActivitySessionType_Sleep,
|
||||
},
|
||||
.activity_sessions[1] = {
|
||||
.start_utc = start_of_today + (1 * SECONDS_PER_HOUR), // 1am
|
||||
.length_min = (4 * MINUTES_PER_HOUR),
|
||||
.type = ActivitySessionType_Sleep,
|
||||
},
|
||||
.activity_sessions[2] = {
|
||||
.start_utc = start_of_today + (2 * SECONDS_PER_HOUR), // 2am
|
||||
.length_min = (1 * MINUTES_PER_HOUR) + 30,
|
||||
.type = ActivitySessionType_RestfulSleep,
|
||||
},
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_sleep_summary_card__render_sleep_late_start_early_end2(void) {
|
||||
const time_t start_of_today = time_util_get_midnight_of(s_now_utc);
|
||||
|
||||
HealthData health_data = {
|
||||
// Used for text
|
||||
.sleep_data[0] = (8 * SECONDS_PER_HOUR) + (12 * SECONDS_PER_MINUTE),
|
||||
.typical_sleep = (10 * SECONDS_PER_HOUR),
|
||||
.monthly_sleep_average = (300 * SECONDS_PER_HOUR),
|
||||
|
||||
// Used for typical
|
||||
.sleep_start = 0 * SECONDS_PER_HOUR,
|
||||
.sleep_end = 7 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_start = -1 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_end = 8 * SECONDS_PER_HOUR,
|
||||
|
||||
// The sleep ring are filled by sleep sessions
|
||||
.num_activity_sessions = 3,
|
||||
.activity_sessions[0] = {
|
||||
.start_utc = start_of_today - (0 * SECONDS_PER_HOUR), // 12am
|
||||
.length_min = (7 * MINUTES_PER_HOUR),
|
||||
.type = ActivitySessionType_Sleep,
|
||||
},
|
||||
.activity_sessions[1] = {
|
||||
.start_utc = start_of_today + (2 * SECONDS_PER_HOUR), // 2am
|
||||
.length_min = (1 * MINUTES_PER_HOUR) + 40,
|
||||
.type = ActivitySessionType_RestfulSleep,
|
||||
},
|
||||
.activity_sessions[2] = {
|
||||
.start_utc = start_of_today + (4 * SECONDS_PER_HOUR), // 4am
|
||||
.length_min = (2 * MINUTES_PER_HOUR),
|
||||
.type = ActivitySessionType_RestfulSleep,
|
||||
},
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_sleep_summary_card__render_sleep_early_start_early_end1(void) {
|
||||
const time_t start_of_today = time_util_get_midnight_of(s_now_utc);
|
||||
|
||||
HealthData health_data = {
|
||||
// Used for text
|
||||
.sleep_data[0] = (8 * SECONDS_PER_HOUR) + (12 * SECONDS_PER_MINUTE),
|
||||
.typical_sleep = (10 * SECONDS_PER_HOUR),
|
||||
.monthly_sleep_average = (300 * SECONDS_PER_HOUR),
|
||||
|
||||
// Used for typical
|
||||
.sleep_start = -3 * SECONDS_PER_HOUR,
|
||||
.sleep_end = 7 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_start = -1 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_end = 8 * SECONDS_PER_HOUR,
|
||||
|
||||
// The sleep ring are filled by sleep sessions
|
||||
.num_activity_sessions = 3,
|
||||
.activity_sessions[0] = {
|
||||
.start_utc = start_of_today - (3 * SECONDS_PER_HOUR), // 9pm
|
||||
.length_min = (10 * MINUTES_PER_HOUR),
|
||||
.type = ActivitySessionType_Sleep,
|
||||
},
|
||||
.activity_sessions[1] = {
|
||||
.start_utc = start_of_today - (2 * SECONDS_PER_HOUR), // 10pm
|
||||
.length_min = (1 * MINUTES_PER_HOUR),
|
||||
.type = ActivitySessionType_RestfulSleep,
|
||||
},
|
||||
.activity_sessions[2] = {
|
||||
.start_utc = start_of_today + (3 * SECONDS_PER_HOUR), // 3am
|
||||
.length_min = (1 * MINUTES_PER_HOUR) + 15,
|
||||
.type = ActivitySessionType_RestfulSleep,
|
||||
},
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
void test_health_sleep_summary_card__render_sleep_early_start_late_end1(void) {
|
||||
const time_t start_of_today = time_util_get_midnight_of(s_now_utc);
|
||||
|
||||
HealthData health_data = {
|
||||
// Used for text
|
||||
.sleep_data[0] = (8 * SECONDS_PER_HOUR) + (12 * SECONDS_PER_MINUTE),
|
||||
.typical_sleep = (10 * SECONDS_PER_HOUR),
|
||||
.monthly_sleep_average = (300 * SECONDS_PER_HOUR),
|
||||
|
||||
// Used for typical
|
||||
.sleep_start = -3 * SECONDS_PER_HOUR,
|
||||
.sleep_end = 7 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_start = -4 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_end = 5 * SECONDS_PER_HOUR,
|
||||
|
||||
// The sleep ring are filled by sleep sessions
|
||||
.num_activity_sessions = 2,
|
||||
.activity_sessions[0] = {
|
||||
.start_utc = start_of_today - (3 * SECONDS_PER_HOUR),
|
||||
.length_min = (3 * MINUTES_PER_HOUR),
|
||||
.type = ActivitySessionType_Sleep,
|
||||
},
|
||||
.activity_sessions[1] = {
|
||||
.start_utc = start_of_today + (1 * SECONDS_PER_HOUR),
|
||||
.length_min = (6 * MINUTES_PER_HOUR),
|
||||
.type = ActivitySessionType_Sleep,
|
||||
},
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
|
||||
|
||||
void test_health_sleep_summary_card__render_sleep_late_start_late_end1(void) {
|
||||
const time_t start_of_today = time_util_get_midnight_of(s_now_utc);
|
||||
|
||||
HealthData health_data = {
|
||||
// Used for text
|
||||
.sleep_data[0] = (8 * SECONDS_PER_HOUR) + (12 * SECONDS_PER_MINUTE),
|
||||
.typical_sleep = (10 * SECONDS_PER_HOUR),
|
||||
.monthly_sleep_average = (300 * SECONDS_PER_HOUR),
|
||||
|
||||
// Used for typical
|
||||
.sleep_start = -4 * SECONDS_PER_HOUR,
|
||||
.sleep_end = 4 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_start = -3 * SECONDS_PER_HOUR,
|
||||
.typical_sleep_end = 3 * SECONDS_PER_HOUR,
|
||||
|
||||
// The sleep ring are filled by sleep sessions
|
||||
.num_activity_sessions = 1,
|
||||
.activity_sessions[0] = {
|
||||
.start_utc = start_of_today - (4 * SECONDS_PER_HOUR),
|
||||
.length_min = (8 * MINUTES_PER_HOUR),
|
||||
.type = ActivitySessionType_Sleep,
|
||||
}
|
||||
};
|
||||
|
||||
prv_create_card_and_render(&health_data);
|
||||
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
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/kino/kino_reel.c" \
|
||||
" src/fw/applib/ui/kino/kino_reel_gbitmap.c" \
|
||||
" src/fw/applib/ui/kino/kino_reel_gbitmap_sequence.c" \
|
||||
" src/fw/applib/ui/kino/kino_reel_pdci.c" \
|
||||
" src/fw/applib/ui/kino/kino_reel_pdcs.c" \
|
||||
" src/fw/applib/ui/layer.c" \
|
||||
" src/fw/applib/ui/menu_layer_system_cells.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"
|
||||
|
||||
health_app_sources = \
|
||||
" src/fw/applib/graphics/gpath_builder.c" \
|
||||
" src/fw/applib/ui/action_button.c" \
|
||||
" src/fw/applib/ui/animation_interpolate.c" \
|
||||
" src/fw/applib/ui/content_indicator.c" \
|
||||
" src/fw/applib/ui/inverter_layer.c" \
|
||||
" src/fw/applib/ui/kino/kino_layer.c" \
|
||||
" src/fw/applib/ui/kino/kino_player.c" \
|
||||
" src/fw/applib/ui/kino/kino_reel/transform.c" \
|
||||
" src/fw/applib/ui/kino/kino_reel_custom.c" \
|
||||
" src/fw/applib/ui/menu_layer.c" \
|
||||
" src/fw/applib/ui/scroll_layer.c" \
|
||||
" src/fw/applib/ui/shadows.c" \
|
||||
" src/fw/applib/ui/text_layer.c" \
|
||||
" src/fw/applib/ui/text_layer_flow.c" \
|
||||
" src/fw/applib/ui/window.c" \
|
||||
" src/fw/apps/system_apps/health/health_data.c" \
|
||||
" src/fw/apps/system_apps/health/health_progress.c" \
|
||||
" src/fw/apps/system_apps/health/health_ui.c" \
|
||||
" src/fw/apps/system_apps/timeline/text_node.c" \
|
||||
" src/fw/services/normal/activity/health_util.c" \
|
||||
" src/fw/services/normal/timeline/timeline_resources.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" \
|
||||
" tests/fixtures/resources/timeline_resource_table.auto.c"
|
||||
|
||||
clar(ctx,
|
||||
sources_ant_glob = rendering_sources + \
|
||||
health_app_sources + \
|
||||
" src/fw/apps/system_apps/health/health_activity_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_activity_summary_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_hr_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_hr_summary_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_sleep_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_sleep_summary_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_card_view.c",
|
||||
test_sources_ant_glob = "test_health_card_view.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'])
|
||||
|
||||
clar(ctx,
|
||||
sources_ant_glob = rendering_sources + \
|
||||
health_app_sources + \
|
||||
" src/fw/apps/system_apps/health/health_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_activity_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_activity_summary_card.c",
|
||||
test_sources_ant_glob = "test_health_activity_summary_card.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'])
|
||||
|
||||
clar(ctx,
|
||||
sources_ant_glob = rendering_sources + \
|
||||
health_app_sources + \
|
||||
" src/fw/apps/system_apps/health/health_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_sleep_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_sleep_summary_card.c",
|
||||
test_sources_ant_glob = "test_health_sleep_summary_card.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'])
|
||||
|
||||
clar(ctx,
|
||||
sources_ant_glob = rendering_sources + \
|
||||
health_app_sources + \
|
||||
" src/fw/apps/system_apps/health/health_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_hr_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_hr_summary_card.c",
|
||||
test_sources_ant_glob = "test_health_hr_summary_card.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=['silk'])
|
||||
|
||||
clar(ctx,
|
||||
sources_ant_glob = rendering_sources + \
|
||||
health_app_sources + \
|
||||
" src/fw/apps/system_apps/health/health_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_activity_detail_card.c",
|
||||
test_sources_ant_glob = "test_health_activity_detail_card.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'])
|
||||
|
||||
clar(ctx,
|
||||
sources_ant_glob = rendering_sources + \
|
||||
health_app_sources + \
|
||||
" src/fw/apps/system_apps/health/health_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_sleep_detail_card.c",
|
||||
test_sources_ant_glob = "test_health_sleep_detail_card.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'])
|
||||
|
||||
clar(ctx,
|
||||
sources_ant_glob = rendering_sources + \
|
||||
health_app_sources + \
|
||||
" src/fw/apps/system_apps/health/health_detail_card.c" \
|
||||
" src/fw/apps/system_apps/health/health_hr_detail_card.c",
|
||||
test_sources_ant_glob = "test_health_hr_detail_card.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'])
|
||||
|
||||
clar(ctx,
|
||||
sources_ant_glob = rendering_sources + \
|
||||
health_app_sources + \
|
||||
" src/fw/apps/system_apps/health/health_detail_card.c",
|
||||
test_sources_ant_glob = "test_health_detail_card.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'])
|
||||
|
||||
# vim:filetype=python
|
||||
Reference in New Issue
Block a user