fix(generator): separate platform and application version info
This commit is contained in:
parent
1f14724603
commit
1f17121b24
|
|
@ -34,6 +34,7 @@ use Rv\Data\Graphics\Stroke\Style as StrokeStyle;
|
|||
use Rv\Data\Graphics\Text;
|
||||
use Rv\Data\Graphics\Text\VerticalAlignment;
|
||||
use Rv\Data\Group;
|
||||
use Rv\Data\HotKey;
|
||||
use Rv\Data\Media;
|
||||
use Rv\Data\Media\ImageTypeProperties;
|
||||
use Rv\Data\Media\Metadata;
|
||||
|
|
@ -45,11 +46,13 @@ use Rv\Data\PresentationSlide;
|
|||
use Rv\Data\Slide;
|
||||
use Rv\Data\Slide\Element as SlideElement;
|
||||
use Rv\Data\Slide\Element\TextScroller;
|
||||
use Rv\Data\Background;
|
||||
use Rv\Data\URL;
|
||||
use Rv\Data\URL\LocalRelativePath;
|
||||
use Rv\Data\URL\Platform as UrlPlatform;
|
||||
use Rv\Data\UUID;
|
||||
use Rv\Data\Version;
|
||||
use Rv\Data\Presentation\Timeline;
|
||||
|
||||
final class ProFileGenerator
|
||||
{
|
||||
|
|
@ -76,6 +79,7 @@ final class ProFileGenerator
|
|||
$group->setUuid(self::uuidFromString($groupUuid));
|
||||
$group->setName($groupData['name']);
|
||||
$group->setColor(self::colorFromArray($groupData['color']));
|
||||
$group->setHotKey(new HotKey());
|
||||
|
||||
$cueIdentifiers = [];
|
||||
foreach ($groupData['slides'] as $slideData) {
|
||||
|
|
@ -126,6 +130,10 @@ final class ProFileGenerator
|
|||
$presentation->setSelectedArrangement($selectedArrangement->getUuid());
|
||||
}
|
||||
|
||||
$presentation->setBackground(self::buildPresentationBackground());
|
||||
$presentation->setChordChart(self::buildChordChartUrl());
|
||||
$presentation->setTimeline(self::buildTimeline());
|
||||
|
||||
self::applyCcliMetadata($presentation, $ccli);
|
||||
|
||||
return new Song($presentation);
|
||||
|
|
@ -146,14 +154,20 @@ final class ProFileGenerator
|
|||
|
||||
private static function buildApplicationInfo(): ApplicationInfo
|
||||
{
|
||||
$version = new Version();
|
||||
$version->setBuild('335544354');
|
||||
$platformVersion = new Version();
|
||||
$platformVersion->setMajorVersion(14);
|
||||
$platformVersion->setMinorVersion(8);
|
||||
$platformVersion->setPatchVersion(3);
|
||||
|
||||
$applicationVersion = new Version();
|
||||
$applicationVersion->setMajorVersion(20);
|
||||
$applicationVersion->setBuild('335544354');
|
||||
|
||||
$applicationInfo = new ApplicationInfo();
|
||||
$applicationInfo->setPlatform(Platform::PLATFORM_MACOS);
|
||||
$applicationInfo->setApplication(Application::APPLICATION_PROPRESENTER);
|
||||
$applicationInfo->setPlatformVersion($version);
|
||||
$applicationInfo->setApplicationVersion($version);
|
||||
$applicationInfo->setPlatformVersion($platformVersion);
|
||||
$applicationInfo->setApplicationVersion($applicationVersion);
|
||||
|
||||
return $applicationInfo;
|
||||
}
|
||||
|
|
@ -199,6 +213,7 @@ final class ProFileGenerator
|
|||
$cue->setUuid(self::uuidFromString($cueUuid));
|
||||
$cue->setActions($actions);
|
||||
$cue->setIsEnabled(true);
|
||||
$cue->setHotKey(new HotKey());
|
||||
if (isset($slideData['label'])) {
|
||||
$cue->setName((string) $slideData['label']);
|
||||
}
|
||||
|
|
@ -455,12 +470,31 @@ final class ProFileGenerator
|
|||
return $color;
|
||||
}
|
||||
|
||||
private static function applyCcliMetadata(Presentation $presentation, array $ccli): void
|
||||
private static function buildPresentationBackground(): Background
|
||||
{
|
||||
if ($ccli === []) {
|
||||
return;
|
||||
$color = new Color();
|
||||
$color->setAlpha(1.0);
|
||||
$background = new Background();
|
||||
$background->setColor($color);
|
||||
return $background;
|
||||
}
|
||||
|
||||
private static function buildChordChartUrl(): URL
|
||||
{
|
||||
$url = new URL();
|
||||
$url->setPlatform(UrlPlatform::PLATFORM_MACOS);
|
||||
return $url;
|
||||
}
|
||||
|
||||
private static function buildTimeline(): Timeline
|
||||
{
|
||||
$timeline = new Timeline();
|
||||
$timeline->setDuration(300.0);
|
||||
return $timeline;
|
||||
}
|
||||
|
||||
private static function applyCcliMetadata(Presentation $presentation, array $ccli): void
|
||||
{
|
||||
$metadata = new CCLI();
|
||||
if (isset($ccli['author'])) {
|
||||
$metadata->setAuthor((string) $ccli['author']);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,46 @@ class ProFileGeneratorTest extends TestCase
|
|||
$this->assertMatchesRegularExpression('/^[A-F0-9]{8}-[A-F0-9]{4}-4[A-F0-9]{3}-[89AB][A-F0-9]{3}-[A-F0-9]{12}$/', $song->getUuid());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function testGenerateCreatesSeparatePlatformAndApplicationVersions(): void
|
||||
{
|
||||
$song = ProFileGenerator::generate(
|
||||
'Version Test',
|
||||
[
|
||||
[
|
||||
'name' => 'V1',
|
||||
'color' => [0, 0, 0, 1],
|
||||
'slides' => [
|
||||
['text' => 'Test'],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
['name' => 'normal', 'groupNames' => ['V1']],
|
||||
],
|
||||
);
|
||||
|
||||
$appInfo = $song->getPresentation()->getApplicationInfo();
|
||||
$this->assertNotNull($appInfo);
|
||||
|
||||
// Verify platform version
|
||||
$platformVersion = $appInfo->getPlatformVersion();
|
||||
$this->assertNotNull($platformVersion);
|
||||
$this->assertSame(14, $platformVersion->getMajorVersion());
|
||||
$this->assertSame(8, $platformVersion->getMinorVersion());
|
||||
$this->assertSame(3, $platformVersion->getPatchVersion());
|
||||
$this->assertSame('', $platformVersion->getBuild());
|
||||
|
||||
// Verify application version
|
||||
$applicationVersion = $appInfo->getApplicationVersion();
|
||||
$this->assertNotNull($applicationVersion);
|
||||
$this->assertSame(20, $applicationVersion->getMajorVersion());
|
||||
$this->assertSame('335544354', $applicationVersion->getBuild());
|
||||
|
||||
// Verify they are different objects
|
||||
$this->assertNotSame($platformVersion, $applicationVersion);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function testGenerateWithMultipleGroupsAndArrangements(): void
|
||||
{
|
||||
|
|
@ -622,4 +662,55 @@ class ProFileGeneratorTest extends TestCase
|
|||
$this->assertEqualsWithDelta(100, $bounds->getOrigin()->getY(), 0.01);
|
||||
$this->assertEqualsWithDelta(150, $bounds->getOrigin()->getX(), 0.01);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function testGeneratePresentationFields(): void
|
||||
{
|
||||
$song = ProFileGenerator::generate(
|
||||
'Fields Test',
|
||||
[
|
||||
[
|
||||
'name' => 'V1',
|
||||
'color' => [0, 0, 0, 1],
|
||||
'slides' => [
|
||||
['text' => 'Test'],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
['name' => 'normal', 'groupNames' => ['V1']],
|
||||
],
|
||||
);
|
||||
|
||||
$p = $song->getPresentation();
|
||||
$this->assertNotNull($p->getBackground());
|
||||
$this->assertNotNull($p->getChordChart());
|
||||
$this->assertNotNull($p->getCcli());
|
||||
$this->assertNotNull($p->getTimeline());
|
||||
$this->assertSame(300.0, $p->getTimeline()->getDuration());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function testGeneratePresentationFieldsWithEmptyCcli(): void
|
||||
{
|
||||
$song = ProFileGenerator::generate(
|
||||
'Empty CCLI Test',
|
||||
[
|
||||
[
|
||||
'name' => 'V1',
|
||||
'color' => [0, 0, 0, 1],
|
||||
'slides' => [
|
||||
['text' => 'Test'],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
['name' => 'normal', 'groupNames' => ['V1']],
|
||||
],
|
||||
[],
|
||||
);
|
||||
|
||||
$p = $song->getPresentation();
|
||||
$this->assertNotNull($p->getCcli(), 'CCLI should be set even when empty array is passed');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue