Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support loading sketches from rss/atom feeds #392

Draft
wants to merge 73 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
f86fcfa
Simple File Cache
TimAidley Feb 9, 2023
8c3abcd
WIP Downloading cache that will either fetch or load local or remote …
TimAidley Feb 9, 2023
ba42ce3
WIP AsyncSketchSet
TimAidley Feb 22, 2023
80324be
Pull in Resource System
TimAidley Feb 22, 2023
a5a892d
Handle async load requests
TimAidley Feb 26, 2023
515aff5
Loading from icosa first grody working version
TimAidley Feb 27, 2023
c77325c
Get rid of those old bit I no longer want
TimAidley Feb 27, 2023
7f2343b
Update to use ResourceFileInfo
TimAidley Feb 27, 2023
01071f3
Load Icosa thumbails from web if available
TimAidley Feb 27, 2023
14f52b2
Rename Contents to ContentsAsync
TimAidley Feb 27, 2023
2421b5b
Rss sketchset
TimAidley Feb 27, 2023
877ecd9
Rename Sketch and SketchSet to ISketch and ISketchSet because they ar…
TimAidley Feb 28, 2023
338b7e2
SketchSets are now identified by type and instance
TimAidley Mar 1, 2023
869d553
Sketchbook now has support for heirarchical sketchsets.
TimAidley Mar 2, 2023
44aca95
Sketchset titles
TimAidley Mar 2, 2023
e7078d6
Filesystem resources kind of working
TimAidley Mar 3, 2023
05214d4
Can load subdirectories
TimAidley Mar 4, 2023
9fd3fd6
Get rid of unnecessary packagemanger include
TimAidley Mar 14, 2023
be15d1c
Move over to use Collection Factories.
TimAidley Mar 20, 2023
a648620
Icosa Gallery added in
TimAidley Mar 20, 2023
79e4da5
Back button works
TimAidley Mar 20, 2023
c494007
Subcollection initialization added.
TimAidley Mar 20, 2023
3a4c9a3
Resource Sketchsets work now with large collections that don't all lo…
TimAidley Mar 21, 2023
ea3e535
Added text to collection objects, and made sketchbook icons prefabs.
TimAidley Mar 21, 2023
0a8d5ac
Make local filesystem sketches writable by default
TimAidley Mar 25, 2023
0bee5ad
Make extra sure streams and associated file handles get closed.
TimAidley Mar 25, 2023
901b31a
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak May 29, 2023
2234591
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jul 10, 2023
270b2cf
Untangle KeyboardPopUpWindow from renaming logic
andybak Jul 14, 2023
d1ff994
Merge branch 'main' into hotfix/better-keyboard-logic
andybak Jul 14, 2023
4b0f1ac
Ensure m_LastInput has a sane value to start with
andybak Jul 14, 2023
de48257
The sketchbook wasn't updating with the renamed sketch
andybak Jul 14, 2023
3b823b9
Merge remote-tracking branch 'upstream/main' into hotfix/better-keybo…
andybak Jul 14, 2023
ff07ed8
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jul 15, 2023
e987954
Merge remote-tracking branch 'upstream/hotfix/better-keyboard-logic' …
andybak Jul 15, 2023
97bda1a
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jul 18, 2023
3558485
Fixes after merging Sketch Renaming and No Headset
andybak Jul 18, 2023
b99e26c
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jul 19, 2023
4d9eaeb
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jul 19, 2023
789b19c
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jul 24, 2023
f9468ee
Unused import
andybak Jul 25, 2023
5f98dd5
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jul 27, 2023
9128083
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jul 28, 2023
4247d47
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jul 30, 2023
ce1df9a
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jul 31, 2023
feb8ee4
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Aug 3, 2023
46b370b
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Aug 3, 2023
0907d25
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Aug 30, 2023
5e8b79f
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Aug 30, 2023
a70c881
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Sep 7, 2023
a2eff70
Post-merge fixes
andybak Sep 7, 2023
8bdf7a7
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Sep 7, 2023
ccf281e
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Sep 12, 2023
a1f504d
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Sep 30, 2023
195477f
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Oct 26, 2023
989e164
Merge branch 'main' into features/showcase_feeds
TimAidley Nov 3, 2023
36fbb21
Remove 'OriginalStream' - I don't remember why it was there and it wa…
TimAidley Nov 4, 2023
3dd2229
Merge sketchbook panel
TimAidley Nov 4, 2023
c85385b
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Nov 23, 2023
a280bf2
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Nov 29, 2023
82bb89a
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Dec 7, 2023
2602969
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Dec 7, 2023
b83d4a6
formatting
andybak Dec 7, 2023
d19d25c
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Dec 20, 2023
6a37747
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Jan 1, 2024
f68e961
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Feb 28, 2024
9ec2c70
Unused import was causing build failures
andybak Feb 28, 2024
9b03863
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Mar 5, 2024
e394063
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak Apr 3, 2024
968bace
Merge remote-tracking branch 'upstream/main'
andybak Apr 7, 2024
79d9655
dotnet-format
andybak Apr 7, 2024
3e20fa3
Merge remote-tracking branch 'upstream/main' into features/showcase_f…
andybak May 3, 2024
5b8ba28
Post-merge fixes (WIP)
andybak May 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Assets/Editor/Tests/TestBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
using NUnit.Framework;
using UnityEditor;
Expand Down Expand Up @@ -64,13 +65,13 @@ void IDisposable.Dispose()
}

[OneTimeSetUp]
public void RunBeforeAnyTests()
public async Task RunBeforeAnyTests()
{
m_container = new GameObject("Singletons for TestBrush");
Coords.AsLocal[m_container.transform] = TrTransform.identity;

var path = Path.Combine(Application.dataPath, "../Support/Sketches/PerfTest/Simple.tilt");
m_testStrokes = GetStrokesFromTilt(path);
m_testStrokes = await GetStrokesFromTiltAsync(path);

if (DevOptions.I == null)
{
Expand Down Expand Up @@ -103,13 +104,13 @@ public void RunAfterAllTests()
}

/// Returns strokes read from the passed .tilt file
public static List<Stroke> GetStrokesFromTilt(string path)
public static async Task<List<Stroke>> GetStrokesFromTiltAsync(string path)
{
var file = new DiskSceneFileInfo(path, readOnly: true);
SketchMetadata metadata;
using (var jsonReader = new JsonTextReader(
new StreamReader(
SaveLoadScript.GetMetadataReadStream(file))))
await SaveLoadScript.GetMetadataReadStreamAsync(file))))
{
// TODO: should cache this?
var serializer = new JsonSerializer();
Expand All @@ -121,7 +122,7 @@ public static List<Stroke> GetStrokesFromTilt(string path)
metadata = serializer.Deserialize<SketchMetadata>(jsonReader);
}

using (var stream = file.GetReadStream(TiltFile.FN_SKETCH))
using (var stream = await file.GetReadStreamAsync(TiltFile.FN_SKETCH))
{
var bufferedStream = new BufferedStream(stream, 4096);
return SketchWriter.GetStrokes(
Expand Down
76 changes: 76 additions & 0 deletions Assets/Editor/Tests/TestDownloadingCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System.IO;
using System.Linq;
using NUnit.Framework;

namespace TiltBrush
{
[TestFixture]
public class TestDownloadingCache
{
private DownloadingCache m_dlCache;
private FileCache m_Cache;
private string m_Path;

private const string kLocalFile = "file://TestData/main_1.png";
private const string kRemoteFile = "http://openbrush.app/assets/icon.png";

[SetUp]
public void Setup()
{
m_Path = Path.Combine(Path.GetTempPath(), "FileCacheTest");
if (File.Exists(m_Path))
{
File.Delete(m_Path);
}
if (Directory.Exists(m_Path))
{
Directory.Delete(m_Path, recursive: true);
}
m_Cache = new FileCache(m_Path, 1);
m_dlCache = new DownloadingCache(m_Cache);
}

[TearDown]
public void Teardown()
{
if (Directory.Exists(m_Path))
{
Directory.Delete(m_Path, recursive: true);
}
}

[Test]
public async void LocalFileLoads()
{
var bytes = await m_dlCache.Read("test", "logo1", kLocalFile);
Assert.That(bytes != null);
Assert.That(bytes.Length == 32983);
}

[Test]
public async void RemoteFileLoads()
{
var bytes = await m_dlCache.Read("test", "logo1", kRemoteFile);
Assert.That(bytes != null);
Assert.That(bytes.Length == 32983);
}

[Test]
public async void RemoteFileIsStoredInCache()
{
var bytes = await m_dlCache.Read("test", "logo1", kRemoteFile);
Assert.That(m_Cache.CacheSize == 32983);
}

[Test]
public async void RemoteFileCanBeLoadedFromCache()
{
var bytes = await m_dlCache.Read("test", "logo1", kRemoteFile);
var bytes2 = m_Cache.Read("test", "logo1");
Assert.That(Enumerable.SequenceEqual(bytes, bytes2));
var bytes3 = await m_dlCache.Read("test", "logo1", kRemoteFile);
Assert.That(Enumerable.SequenceEqual(bytes, bytes3));
}

}
}
3 changes: 3 additions & 0 deletions Assets/Editor/Tests/TestDownloadingCache.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

142 changes: 142 additions & 0 deletions Assets/Editor/Tests/TestFileCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
using System.IO;
using System.Linq;
using NUnit.Framework;

namespace TiltBrush
{
[TestFixture]
internal class TestFileCache
{
private FileCache m_Cache;
private string m_Path;
[SetUp]
public void Setup()
{
m_Path = Path.Combine(Path.GetTempPath(), "FileCacheTest");
if (File.Exists(m_Path))
{
File.Delete(m_Path);
}
if (Directory.Exists(m_Path))
{
Directory.Delete(m_Path, recursive: true);
}
m_Cache = new FileCache(m_Path, 1);
}

[TearDown]
public void Teardown()
{
if (Directory.Exists(m_Path))
{
Directory.Delete(m_Path, recursive: true);
}
}

[Test]
public void IsDirectoryCreated()
{
Assert.IsTrue(Directory.Exists(m_Path));
}

[Test]
public void IsCacheSizeUpdated()
{
Assert.That(m_Cache.CacheSize == 0);
byte[] bytes = new byte[1000];
m_Cache.Write("test", "onethousand", bytes);
Assert.That(m_Cache.CacheSize == 1000);
}

[Test]
public void IsCacheLimitRespected()
{
byte[] bytes = new byte[100000];
for (int i = 0; i < 11; i++)
{
m_Cache.Write($"test_{i}", "100kbytes", bytes);
}
Assert.That(m_Cache.CacheSize == 1000000);
var rootDir = new DirectoryInfo(m_Path);
Assert.That(rootDir.EnumerateFiles("*", SearchOption.AllDirectories)
.Sum(x => x.Length) == 1000000);
}

[Test]
public void IsLastCreatedExpunged()
{
byte[] bytes = new byte[100000];
for (int i = 0; i < 11; i++)
{
m_Cache.Write($"test_{i}", "100kbytes", bytes);
}
Assert.IsFalse(m_Cache.FilesetExists("test_0"));
}

[Test]
public void CanWriteMultipleFilesSetAndFiles()
{
byte[] bytes = new byte[1000];
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; ++j)
{
m_Cache.Write($"test_{i}", $"100kbytes_{j}", bytes);
}
}

for (int i = 0; i < 5; i++)
{
Assert.That(m_Cache.FilesetExists($"test_{i}"));
for (int j = 0; j < 5; ++j)
{
Assert.That(m_Cache.FileExists($"test_{i}", $"100kbytes_{j}"));
}
}
}

[Test]
public void ThingsThatDontExistDontExist()
{
byte[] bytes = new byte[1000];
m_Cache.Write("Real", "onethousand", bytes);

Assert.IsFalse(m_Cache.FilesetExists("Imaginary"));
Assert.IsFalse(m_Cache.FileExists("Imaginary", "onethousand"));
Assert.IsFalse(m_Cache.FileExists("Real", "twothousand"));
}

[Test]
public void FilesCanBeDeleted()
{
byte[] bytes = new byte[1000];
m_Cache.Write("Real", "onethousand", bytes);
Assert.That(m_Cache.FileExists("Real", "onethousand"));
m_Cache.DeleteFile("Real", "onethousand");
Assert.That(!m_Cache.FileExists("Real", "onethousand"));
}

[Test]
public void FileHasTheRightContents()
{
byte[] bytes = Enumerable.Range(0, 127).Select(x => (byte)x).ToArray();
m_Cache.Write("test", "data", bytes);
byte[] read = m_Cache.Read("test", "data");
Assert.That(bytes.SequenceEqual(read));
}

[Test]
public void TestStreamRead()
{
byte[] bytes = Enumerable.Range(0, 127).Select(x => (byte)x).ToArray();
m_Cache.Write("test", "data", bytes);
using (var stream = m_Cache.ReadStream("test", "data"))
{
for (int i = 0; i < 127; ++i)
{
Assert.That(stream.ReadByte() == i);
}
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/Editor/Tests/TestFileCache.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading