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.
|
2019-12-24 02:31:46 +00:00
|
|
|
_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--) {
|
2019-10-30 02:36:29 +00:00
|
|
|
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)
|
2019-10-30 02:36:29 +00:00
|
|
|
XCTAssertEqual(remaining_time_in_state, _video->get_next_sequence_point().as_integral());
|
2019-07-10 03:27:27 +00:00
|
|
|
}
|
|
|
|
vsync ^= true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|