mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add test data to db for VisualTests
Also fixes the broken IPC condition
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Desktop;
|
using osu.Framework.Desktop;
|
||||||
|
using osu.Framework.Desktop.Platform;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
|
|
||||||
namespace osu.Framework.VisualTests
|
namespace osu.Framework.VisualTests
|
||||||
|
@ -5,15 +5,77 @@ using osu.Framework.GameModes.Testing;
|
|||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game;
|
using osu.Game;
|
||||||
|
using osu.Framework.Desktop.Platform;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Game.GameModes.Play;
|
||||||
|
using SQLiteNetExtensions.Extensions;
|
||||||
|
|
||||||
namespace osu.Framework.VisualTests
|
namespace osu.Framework.VisualTests
|
||||||
{
|
{
|
||||||
class VisualTestGame : OsuGameBase
|
class VisualTestGame : OsuGameBase
|
||||||
{
|
{
|
||||||
|
private void InsertTestMap(int i)
|
||||||
|
{
|
||||||
|
var beatmapSet = new BeatmapSetInfo
|
||||||
|
{
|
||||||
|
BeatmapSetID = 1234 + i,
|
||||||
|
Hash = "d8e8fca2dc0f896fd7cb4cb0031ba249",
|
||||||
|
Path = "/foo/bar/baz",
|
||||||
|
Metadata = new BeatmapMetadata
|
||||||
|
{
|
||||||
|
BeatmapSetID = 1234 + i,
|
||||||
|
Artist = "MONACA",
|
||||||
|
Title = "Black Song",
|
||||||
|
Author = "Some Guy",
|
||||||
|
},
|
||||||
|
Beatmaps = new List<BeatmapInfo>(new[]
|
||||||
|
{
|
||||||
|
new BeatmapInfo
|
||||||
|
{
|
||||||
|
BeatmapID = 1234 + i,
|
||||||
|
Mode = PlayMode.Osu,
|
||||||
|
Path = "normal.osu",
|
||||||
|
Version = "Normal",
|
||||||
|
BaseDifficulty = new BaseDifficulty
|
||||||
|
{
|
||||||
|
OverallDifficulty = 3.5f,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new BeatmapInfo
|
||||||
|
{
|
||||||
|
BeatmapID = 1235 + i,
|
||||||
|
Mode = PlayMode.Osu,
|
||||||
|
Path = "hard.osu",
|
||||||
|
Version = "Hard",
|
||||||
|
BaseDifficulty = new BaseDifficulty
|
||||||
|
{
|
||||||
|
OverallDifficulty = 5,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new BeatmapInfo
|
||||||
|
{
|
||||||
|
BeatmapID = 1236 + i,
|
||||||
|
Mode = PlayMode.Osu,
|
||||||
|
Path = "insane.osu",
|
||||||
|
Version = "Insane",
|
||||||
|
BaseDifficulty = new BaseDifficulty
|
||||||
|
{
|
||||||
|
OverallDifficulty = 7,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
BeatmapDatabase.Connection.InsertWithChildren(beatmapSet, true);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
public override void Load(BaseGame game)
|
||||||
{
|
{
|
||||||
|
(Host.Storage as DesktopStorage).InMemorySQL = true;
|
||||||
base.Load(game);
|
base.Load(game);
|
||||||
|
for (int i = 0; i < 100; i += 10)
|
||||||
|
InsertTestMap(i);
|
||||||
Add(new TestBrowser());
|
Add(new TestBrowser());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,15 +81,22 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="mscorlib" />
|
<Reference Include="mscorlib" />
|
||||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\ppy.OpenTK.2.0.50727.1337\lib\net20\OpenTK.dll</HintPath>
|
<HintPath>$(SolutionDir)\packages\ppy.OpenTK.2.0.50727.1337\lib\net20\OpenTK.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="SQLite.Net">
|
||||||
|
<HintPath>$(SolutionDir)\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SQLiteNetExtensions">
|
||||||
|
<HintPath>$(SolutionDir)\packages\SQLiteNetExtensions.1.3.0\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\SQLiteNetExtensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\osu.licenseheader">
|
<None Include="..\osu.licenseheader">
|
||||||
<Link>osu.licenseheader</Link>
|
<Link>osu.licenseheader</Link>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
@ -170,4 +177,4 @@
|
|||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
7
osu.Desktop.VisualTests/packages.config
Normal file
7
osu.Desktop.VisualTests/packages.config
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
|
||||||
|
<package id="SQLite.Net.Core-PCL" version="3.1.1" targetFramework="net45" />
|
||||||
|
<package id="SQLite.Net-PCL" version="3.0.5" targetFramework="net45" />
|
||||||
|
<package id="SQLiteNetExtensions" version="1.3.0" targetFramework="net45" />
|
||||||
|
</packages>
|
@ -25,7 +25,7 @@ namespace osu.Desktop
|
|||||||
var importer = new BeatmapImporter(host);
|
var importer = new BeatmapImporter(host);
|
||||||
|
|
||||||
foreach (var file in args)
|
foreach (var file in args)
|
||||||
if (importer.Import(file).Wait(1000))
|
if (!importer.Import(file).Wait(1000))
|
||||||
throw new TimeoutException(@"IPC took too long to send");
|
throw new TimeoutException(@"IPC took too long to send");
|
||||||
Console.WriteLine(@"Sent import requests to running instance");
|
Console.WriteLine(@"Sent import requests to running instance");
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
public class BeatmapDatabase
|
public class BeatmapDatabase
|
||||||
{
|
{
|
||||||
private static SQLiteConnection connection { get; set; }
|
public static SQLiteConnection Connection { get; set; }
|
||||||
private BasicStorage storage;
|
private BasicStorage storage;
|
||||||
public event Action<BeatmapSetInfo> BeatmapSetAdded;
|
public event Action<BeatmapSetInfo> BeatmapSetAdded;
|
||||||
|
|
||||||
@ -29,13 +29,13 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
ipc = new BeatmapImporter(host, this);
|
ipc = new BeatmapImporter(host, this);
|
||||||
|
|
||||||
if (connection == null)
|
if (Connection == null)
|
||||||
{
|
{
|
||||||
connection = storage.GetDatabase(@"beatmaps");
|
Connection = storage.GetDatabase(@"beatmaps");
|
||||||
connection.CreateTable<BeatmapMetadata>();
|
Connection.CreateTable<BeatmapMetadata>();
|
||||||
connection.CreateTable<BaseDifficulty>();
|
Connection.CreateTable<BaseDifficulty>();
|
||||||
connection.CreateTable<BeatmapSetInfo>();
|
Connection.CreateTable<BeatmapSetInfo>();
|
||||||
connection.CreateTable<BeatmapInfo>();
|
Connection.CreateTable<BeatmapInfo>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,10 +44,10 @@ namespace osu.Game.Database
|
|||||||
foreach (var setInfo in Query<BeatmapSetInfo>())
|
foreach (var setInfo in Query<BeatmapSetInfo>())
|
||||||
storage.Delete(setInfo.Path);
|
storage.Delete(setInfo.Path);
|
||||||
|
|
||||||
connection.DeleteAll<BeatmapMetadata>();
|
Connection.DeleteAll<BeatmapMetadata>();
|
||||||
connection.DeleteAll<BaseDifficulty>();
|
Connection.DeleteAll<BaseDifficulty>();
|
||||||
connection.DeleteAll<BeatmapSetInfo>();
|
Connection.DeleteAll<BeatmapSetInfo>();
|
||||||
connection.DeleteAll<BeatmapInfo>();
|
Connection.DeleteAll<BeatmapInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Import(params string[] paths)
|
public void Import(params string[] paths)
|
||||||
@ -62,7 +62,7 @@ namespace osu.Game.Database
|
|||||||
using (var reader = ArchiveReader.GetReader(storage, path))
|
using (var reader = ArchiveReader.GetReader(storage, path))
|
||||||
metadata = reader.ReadMetadata();
|
metadata = reader.ReadMetadata();
|
||||||
|
|
||||||
if (connection.Table<BeatmapSetInfo>().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0)
|
if (Connection.Table<BeatmapSetInfo>().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0)
|
||||||
return; // TODO: Update this beatmap instead
|
return; // TODO: Update this beatmap instead
|
||||||
|
|
||||||
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
|
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
|
||||||
@ -104,7 +104,7 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connection.InsertWithChildren(beatmapSet, true);
|
Connection.InsertWithChildren(beatmapSet, true);
|
||||||
BeatmapSetAdded?.Invoke(beatmapSet);
|
BeatmapSetAdded?.Invoke(beatmapSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,25 +136,25 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
public TableQuery<T> Query<T>() where T : class
|
public TableQuery<T> Query<T>() where T : class
|
||||||
{
|
{
|
||||||
return connection.Table<T>();
|
return Connection.Table<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T GetWithChildren<T>(object id) where T : class
|
public T GetWithChildren<T>(object id) where T : class
|
||||||
{
|
{
|
||||||
return connection.GetWithChildren<T>(id);
|
return Connection.GetWithChildren<T>(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<T> GetAllWithChildren<T>(Expression<Func<T, bool>> filter = null,
|
public List<T> GetAllWithChildren<T>(Expression<Func<T, bool>> filter = null,
|
||||||
bool recursive = true) where T : class
|
bool recursive = true) where T : class
|
||||||
{
|
{
|
||||||
return connection.GetAllWithChildren<T>(filter, recursive);
|
return Connection.GetAllWithChildren<T>(filter, recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T GetChildren<T>(T item, bool recursive = true)
|
public T GetChildren<T>(T item, bool recursive = true)
|
||||||
{
|
{
|
||||||
if (item == null) return default(T);
|
if (item == null) return default(T);
|
||||||
|
|
||||||
connection.GetChildren(item, recursive);
|
Connection.GetChildren(item, recursive);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,9 +171,9 @@ namespace osu.Game.Database
|
|||||||
if (!validTypes.Any(t => t == typeof(T)))
|
if (!validTypes.Any(t => t == typeof(T)))
|
||||||
throw new ArgumentException(nameof(T), "Must be a type managed by BeatmapDatabase");
|
throw new ArgumentException(nameof(T), "Must be a type managed by BeatmapDatabase");
|
||||||
if (cascade)
|
if (cascade)
|
||||||
connection.UpdateWithChildren(record);
|
Connection.UpdateWithChildren(record);
|
||||||
else
|
else
|
||||||
connection.Update(record);
|
Connection.Update(record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user