-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into chore-cppcheck-2.14.1
- Loading branch information
Showing
4 changed files
with
94 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include "tst.h" | ||
#include "asserts.h" | ||
#include "util.h" | ||
|
||
#include <cmocka.h> | ||
#include <stdbool.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <wayland-client-protocol.h> | ||
|
||
#include "cfg.h" | ||
#include "slist.h" | ||
#include "log.h" | ||
#include "info.h" | ||
|
||
#include "listeners.h" | ||
|
||
int before_all(void **state) { | ||
return 0; | ||
} | ||
|
||
int after_all(void **state) { | ||
return 0; | ||
} | ||
|
||
int before_each(void **state) { | ||
return 0; | ||
} | ||
|
||
int after_each(void **state) { | ||
assert_logs_empty(); | ||
|
||
return 0; | ||
} | ||
|
||
void preferred__first(void **state) { | ||
struct Head head = { .name = "NAM", }; | ||
struct Mode mode_existing = { .width = 3840, .height = 2160, .preferred = false, .refresh_mhz = 60000, .head = &head, }; | ||
struct Mode mode_preferred = { .width = 2560, .height = 1440, .preferred = false, .refresh_mhz = 30000, .head = &head, }; | ||
|
||
slist_append(&head.modes, &mode_existing); | ||
slist_append(&head.modes, &mode_preferred); | ||
|
||
zwlr_output_mode_listener()->preferred(&mode_preferred, NULL); | ||
|
||
assert_false(mode_existing.preferred); | ||
assert_true(mode_preferred.preferred); | ||
|
||
slist_free(&head.modes); | ||
} | ||
|
||
void preferred__subsequent(void **state) { | ||
struct Head head = { .name = "NAM", }; | ||
struct Mode mode_existing = { .width = 3840, .height = 2160, .preferred = true, .refresh_mhz = 60000, .head = &head, }; | ||
struct Mode mode_subsequent = { .width = 2560, .height = 1440, .preferred = false, .refresh_mhz = 30000, .head = &head, }; | ||
|
||
slist_append(&head.modes, &mode_existing); | ||
slist_append(&head.modes, &mode_subsequent); | ||
|
||
zwlr_output_mode_listener()->preferred(&mode_subsequent, NULL); | ||
|
||
assert_log(INFO, "\nNAM: multiple preferred modes advertised: using initial 3840x2160@60Hz (60,000mHz) (preferred), ignoring 2560x1440@30Hz (30,000mHz)\n"); | ||
|
||
assert_true(mode_existing.preferred); | ||
assert_false(mode_subsequent.preferred); | ||
|
||
slist_free(&head.modes); | ||
} | ||
|
||
int main(void) { | ||
const struct CMUnitTest tests[] = { | ||
TEST(preferred__first), | ||
TEST(preferred__subsequent) | ||
}; | ||
|
||
return RUN(tests); | ||
} | ||
|