Commit Graph

191 Commits

Author SHA1 Message Date
541237ef16 Use a shorter test beatmap for tests which need to run to completion 2021-02-22 14:48:04 +09:00
8eb1076fd7 Add test coverage 2020-12-07 18:18:14 +09:00
eb38bc4b4c Add the ability to import into ArchiveModelManagers from a stream 2020-12-07 18:09:18 +09:00
8a54fdd4e6 Ensure LoadOszIntoOsu returns actual imported map 2020-11-01 14:25:33 +01:00
3cef93ee27 Centralise import test helper methods 2020-09-18 18:05:33 +09:00
0b289d2e77 Add hostname differentiation to beatmap tests too 2020-09-17 13:07:05 +09:00
5268eee0fb Avoid requiring sending the calling method for CleanRunHeadlessGameHost 2020-09-08 11:31:42 +09:00
01c0b61b20 Fix incorrect test names 2020-09-08 01:52:31 +09:00
fba253f131 Take user argument in CreateNew method parameters 2020-09-04 13:17:43 +09:00
d3fbc7cc53 Use more direct reference in tests 2020-09-04 13:16:35 +09:00
c9a73926a6 Add basic test coverage 2020-09-03 19:38:01 +09:00
880a127228 Use async overload 2020-06-10 00:08:48 +09:00
88aed1d504 Merge branch 'master' into update-inspectcode-version 2020-06-09 20:12:39 +09:00
8a021e0beb Use save method in test 2020-06-08 22:35:01 +09:00
b41384dde8 Merge branch 'master' into multiplayer-beatmap-checksum 2020-06-07 18:05:33 +09:00
66ec2afe5c Remove broken import test 2020-06-03 23:38:40 +09:00
5ed3cd205f Simplify reuse check using FileInfo IDs 2020-06-03 23:35:56 +09:00
25160dc220 Fix test name 2020-06-03 19:15:52 +09:00
012933545e Add test coverage 2020-06-03 18:33:41 +09:00
f3b5149648 Move some suggestions to warnings, resolve issues 2020-06-03 16:48:44 +09:00
dfb9687fb5 Extract update into PreUpdate(), add test 2020-06-02 17:22:09 +09:00
f989f1aa00 Change event flow to avoid firing store delete events on update 2020-05-27 16:08:47 +09:00
052ad79fc6 Convert dangerous events to IBindables 2020-05-19 16:44:22 +09:00
0e2ccac33b Add spaces to comments 2020-05-04 18:36:24 -07:00
370ff70dd4 Fix incorrect host name specification 2020-03-17 18:32:30 +09:00
363d7d724a Use old ctor params 2020-01-15 14:02:29 +09:00
0e844b3039 Cleanup / re-protect file store 2020-01-14 19:24:53 +09:00
4b8d628000 Remove file addition test 2020-01-14 19:24:53 +09:00
524ff41931 Add more assertions 2020-01-14 19:24:53 +09:00
b592b6d80d Improve robustness by always creating a new file 2020-01-14 19:24:53 +09:00
000fc836b2 Remove unused class 2020-01-14 19:24:53 +09:00
dce93dfe7c Split test 2020-01-14 19:24:53 +09:00
609102bea3 Initial file updating implementation 2020-01-14 19:24:53 +09:00
681a43a318 Refactor to support beatmap updates 2020-01-14 19:24:53 +09:00
9f62ec869a Add failing test 2019-11-14 19:38:20 +09:00
26a33bfa4e Merge branch 'master' into fix-resume-from-player-audio 2019-10-11 19:21:14 +09:00
c7eb0b401b Merge branch 'master' into ignore-macosx-folder-in-archives 2019-10-11 14:36:52 +09:00
11acd177f1 Add import test with files to be filtered out
Add a test case reproducing the conditions encountered "in the wild"
wherein a skin import would be performed incorrectly due to a __MACOSX
resource fork directory present next to a directory with the actual skin
files in the archive.
2019-10-10 23:54:17 +02:00
c8ffc134d4 Use nameof when instantiating headless game hosts
As a purely cosmetic code improvement, substitute string literals
in constructor calls of HeadlessGameHost in ImportBeatmapTest for nameof
operator usages.
2019-10-10 22:36:43 +02:00
cb1f7e2dc7 Fix platform dependency in buffered reader test
Tests for the line-buffered reader added in 7b1ff38 were subtly
dependent on the execution environment due to differing end-of-line
markers on Windows and Unix-based systems.

Because StreamReader discards all newlines when reading line-by-line,
LineBufferedReader used a StringBuilder to patch the peeked lines
back together with the remaining contents of the file being read.
As StringBuilder.AppendLine uses the environment-specific newline
delimiter, the delimiters after the peeked-but-unconsumed lines can
therefore be substituted by the platform-specific variants, causing
the test failures due to the overly-simplified way they were written.

Reformulate the test to avoid such issues from resurfacing again
by splitting lines by \r or \n and then testing each line individually.
Additionally remove all raw literals in favour of explicitly mixing
various line delimiter character sequences for additional coverage.
2019-10-10 15:33:18 +02:00
8df2e359c4 Fix tests on CI 2019-10-10 17:42:15 +09:00
6268bbcfc8 Merge branch 'master' into beatmap-parsing-fallback-v2 2019-10-03 15:12:21 +08:00
a06cb54732 Merge branch 'master' into beatmap-parsing-fallback-v2 2019-09-20 15:28:08 +09:00
f306fe27d8 Add test to cover corruption case 2019-09-20 15:05:48 +09:00
ddff9882cf Fix importing archives which are nested in a single folder within a zip 2019-09-19 19:11:04 +09:00
86588778b1 Implement fallback decoder registration
After the preparatory introduction of LineBufferedReader, it is now
possible to introduce registration of fallback decoders that won't drop
input supplied in the first line of the file.

A fallback decoder is used when the magic in the first line of the file
does not match any of the other known decoders. In such a case,
the fallback decoder is constructed and provided a LineBufferedReader
instance. The process of matching magic only peeks the first non-empty
line, so it is available for re-reading in Decode() using ReadLine().

There can be only one fallback decoder per type; a second attempt of
registering a fallback will result in an exception to avoid bugs.

To address the issue of parsing failing on badly or non-headered files,
set the legacy decoders for Beatmaps and Storyboards as the fallbacks.

Due to non-trivial logic, several new, passing unit tests with possible
edge cases also included.
2019-09-15 01:28:07 +02:00
11eda44d34 Migrate decoding to line-buffered reader
Migrate all usages of StreamReader in the context of decoding beatmaps,
storyboards or skins to the new LineBufferedReader.
2019-09-15 01:28:07 +02:00
7b1ff38df7 Implement line-buffered reader
Add a line-buffered reader decorator operating on StreamReader
instances. The decorator has two main operations - PeekLine(), which
allows to see the next line in the stream without consuming it,
ReadLine(), which consumes and returns the next line in the stream, and
ReadToEnd() which reads all the remaining text in the stream (including
the unconsumed peeked line). Peeking line-per-line uses an internal
queue of lines that have been read ahead from the underlying stream.

The addition of the line-buffered reader is a workaround solution to
a problem with decoding. At current selecting a decoder works by
irreversibly reading the first line from the stream and looking for
a magic string that indicates the type of decoder to use.

It might however be possible for a file to be valid in format, just
missing a header. In such a case a lack of a line-buffered reader makes
it impossible to reparse the content of that first line. Introducing it
will however allow to peek the first line for magic first.

 - If magic is found in the first line, GetDecoder() will peek it and
   use it to return the correct Decoder instance. Note that in the case
   of JsonBeatmapDecoder the magic is the opening JSON object brace,
   and therefore must not be consumed.

 - If magic is not found, the fallback decoder will be able to consume
   it using ReadLine() in Decode().

This commit additionally contains basic unit tests for the reader.

Suggested-by: Aergwyn <aergwyn@t-online.de>
2019-09-15 01:26:15 +02:00
9e1cb90dd8 Remove existing argument for ItemAdded event
For all usages, it looks like this was unnecessary.
2019-06-26 11:40:41 +09:00
12aa264657 Consolidate tests and check for file reference counts 2019-06-10 18:35:23 +09:00