Skip to content

Commit

Permalink
unit tests can raise exception
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanArbuckle committed Dec 20, 2020
1 parent b625aa6 commit 22f6585
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
1 change: 1 addition & 0 deletions CRCarplayWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ id getCarplayCADisplay(void)
return display;
}
}

return nil;
}

Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ after-install::
install.exec "killall -9 SpringBoard CarPlay"

test::
install.exec "cycript -p SpringBoard" < tests.cy
install.exec "cycript -p SpringBoard" < tests/springboard_tests.cy
install.exec "cycript -p CarPlay" < tests/carplay_tests.cy
18 changes: 18 additions & 0 deletions tests/carplay_tests.cy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function assert_not_null(cond, desc) {
if (typeof cond === "undefined" || cond === null) {
[NSException raise:@"Carplay Test Failed" format:desc];
}
}

function test_app_library_includes_all_apps()
{
// When an application library is created
appLibrary = [CARApplication _newApplicationLibrary];
assert_not_null(appLibrary, @"_newApplicationLibrary is NULL");

// It includes apps that are normally excluded/unsupported
appInfo = [appLibrary applicationInfoForBundleIdentifier: @"com.netflix.Netflix"];
assert_not_null(appInfo, @"app library did not include unsupported apps");
}

test_app_library_includes_all_apps();
36 changes: 18 additions & 18 deletions tests.cy → tests/springboard_tests.cy
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@

function assert_not_null(a) {
if (typeof a === "undefined" || a === null) {
NSLog("FAIL: " + a + " === nil");
function assert_not_null(cond, desc)
{
if (typeof cond === "undefined" || cond === null) {
[NSException raise:@"Carplay Test Failed" format:desc];
}
}

function assert_equal(a, b) {
function assert_equal(a, b, desc)
{
if (![a isEqual:b]) {
NSLog("FAIL: " + a + " !== " + b);
[NSException raise:@"Carplay Test Failed" format:desc];
}
}

function validate_live_window(window)
{
assert_not_null(window);
assert_not_null(window, @"carplay window does not exist");

// The root window was created and visible
rootWindow = [window rootWindow];
assert_not_null(rootWindow);
assert_equal([rootWindow isHidden], @(NO));
assert_not_null(rootWindow, @"rootWindow is null");
assert_equal([rootWindow isHidden], @(NO), @"rootWindow is not visible");

// The splash imageview was created
splash_image_view = [window launchImageView];
assert_not_null(splash_image_view);
assert_not_null(splash_image_view, @"failed to create splash image view");

// And it has an image
splash_image = [splash_image_view image];
assert_not_null(splash_image);
assert_not_null(splash_image, @"failed to create splash image");

assert_not_null([window application]);
assert_not_null([window appViewController]);
assert_not_null([window dockView]);
assert_not_null([window sceneMonitor]);
assert_not_null([window application], @"failed to create sbapplication");
assert_not_null([window appViewController], @"failed to create app controller");
assert_not_null([window dockView], @"failed to create dock view");
assert_not_null([window sceneMonitor], @"failed to create scenemonitor");

// It is not in fullscreen mode
assert_equal([window isFullscreen], @(NO));
assert_equal([window isFullscreen], @(NO), @"rootWindow started in fullscreen");

// It starts in landscape
assert_equal([window orientation], @(3));
assert_equal([window orientation], @(3), @"window started in unexpected orientation");
}

function launch_window_device_locked()
Expand Down Expand Up @@ -74,7 +75,6 @@ function launch_window_device_unlocked()
[live_window dismiss];
}


launch_window_device_locked();

sleep(1);
Expand Down

0 comments on commit 22f6585

Please sign in to comment.