1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-11 14:05:21 +00:00
CLK/OSBindings/Mac/Clock SignalTests/MacintoshVideoTests.mm

48 lines
1.3 KiB
Plaintext
Raw Normal View History

2019-07-10 03:27:27 +00:00
//
// MacintoshVideoTests.m
// Clock SignalTests
//
// Created by Thomas Harte on 09/07/2019.
// Copyright © 2019 Thomas Harte. All rights reserved.
//
#import <XCTest/XCTest.h>
#include <memory>
#include "../../../Machines/Apple/Macintosh/Video.hpp"
@interface MacintoshVideoTests : XCTestCase
@end
@implementation MacintoshVideoTests {
Apple::Macintosh::DeferredAudio _dummy_audio;
Apple::Macintosh::DriveSpeedAccumulator _dummy_drive_speed_accumulator;
std::unique_ptr<Apple::Macintosh::Video> _video;
uint16_t _ram[64*1024];
}
- (void)setUp {
// Put setup code here. This method is called before the invocation of each test method in the class.
_video = std::make_unique<Apple::Macintosh::Video>(_dummy_audio, _dummy_drive_speed_accumulator);
2019-10-28 01:30:58 +00:00
_video->set_ram(_ram, sizeof(_ram) - 1);
2019-07-10 03:27:27 +00:00
}
- (void)testPrediction {
int c = 5;
bool vsync = _video->vsync();
while(c--) {
auto remaining_time_in_state = _video->get_next_sequence_point().as_integral();
2019-07-10 03:27:27 +00:00
NSLog(@"Vsync %@ expected for %@ half-cycles", vsync ? @"on" : @"off", @(remaining_time_in_state));
while(remaining_time_in_state--) {
XCTAssertEqual(vsync, _video->vsync());
_video->run_for(HalfCycles(1));
if(remaining_time_in_state)
XCTAssertEqual(remaining_time_in_state, _video->get_next_sequence_point().as_integral());
2019-07-10 03:27:27 +00:00
}
vsync ^= true;
}
}
@end