Skip to content

Commit

Permalink
Add Display test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Apprentice-Alchemist committed Jun 20, 2022
1 parent 6fb8266 commit a67d56b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
**/Deployment/MultiWindow
compile_commands.json
.vscode/**
**/Deployment/**
!**/Deployment/keepme*
Empty file added Tests/Display/Deployment/keepme
Empty file.
45 changes: 45 additions & 0 deletions Tests/Display/Sources/display.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "kinc/string.h"
#include <kinc/display.h>
#include <kinc/log.h>

void print_mode(const char *indent, kinc_display_mode_t mode) {
kinc_log(KINC_LOG_LEVEL_INFO, "%sx: %i", indent, mode.x);
kinc_log(KINC_LOG_LEVEL_INFO, "%sy: %i", indent, mode.y);
kinc_log(KINC_LOG_LEVEL_INFO, "%swidth: %i", indent, mode.width);
kinc_log(KINC_LOG_LEVEL_INFO, "%sheight: %i", indent, mode.height);
kinc_log(KINC_LOG_LEVEL_INFO, "%spixels_per_inch: %i", indent, mode.pixels_per_inch);
kinc_log(KINC_LOG_LEVEL_INFO, "%sfrequency: %i", indent, mode.frequency);
kinc_log(KINC_LOG_LEVEL_INFO, "%sbits_per_pixel: %i", indent, mode.bits_per_pixel);
}

int kickstart(int argc, char **argv) {
bool print_modes = false;
if (argc > 1 && kinc_string_compare(argv[1], "--print-modes") == 0) {
print_modes = true;
}
kinc_display_init();
int count = kinc_count_displays();
kinc_log(KINC_LOG_LEVEL_INFO, "display count: %i", count);
kinc_log(KINC_LOG_LEVEL_INFO, "primary display: %i", kinc_primary_display());
for (int i = 0; i < count; i++) {
bool available = kinc_display_available(i);
kinc_log(KINC_LOG_LEVEL_INFO, "display %i:", i);
kinc_log(KINC_LOG_LEVEL_INFO, "\tavailable: %s", available ? "true" : "false");
if (available) {
kinc_log(KINC_LOG_LEVEL_INFO, "\tname: %s", kinc_display_name(i));
kinc_display_mode_t mode = kinc_display_current_mode(i);
print_mode("\t", mode);
kinc_log(KINC_LOG_LEVEL_INFO, "");
int mode_count = kinc_display_count_available_modes(i);
kinc_log(KINC_LOG_LEVEL_INFO, "\tavailable modes: %i", mode_count);
if (print_modes) {
for (int j = 0; j < mode_count; j++) {
kinc_display_mode_t mode = kinc_display_available_mode(i, j);
print_mode("\t\t", mode);
kinc_log(KINC_LOG_LEVEL_INFO, "");
}
}
}
}
return 0;
}
10 changes: 10 additions & 0 deletions Tests/Display/kfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const project = new Project('DisplayTest');

await project.addProject('../../');

project.addFile('Sources/**');
project.setDebugDir('Deployment');

project.flatten();

resolve(project);

0 comments on commit a67d56b

Please sign in to comment.