damus/damusTests
Daniel D’Aquino 26d2627a1c Cache videos
This commit implements a simple but functional video cache.

It works by providing a method called `maybe_cached_url`, where a video
URL can be passed in, and this method will either return the URL of a
cached version of this video if available, or the original URL if not. It also
downloads new video URLs on the background into the cache folder for use
next time.

Functional testing
-------------------

PASS

Device: iPhone 15 simulator
iOS: 17.4
Damus: Approximately this commit
Setup:
- Debug connection
- Expiry time locally changed to 5 minutes

Steps:
1. Basic functionality
  1. Go to a profile with lots of videos
  2. Scroll down
  3. Filter logs to only logs that start with "Loading video with URL"
  4. Check that most videos are being loaded from external URLs. PASS
  5. Now restart the app and go to that same profile
  6. Scroll down and watch logs. Videos should now be loaded with an internal file URL. PASS
2. Automatic cache refresh after expiry
  1. Go to the video-heavy profile, make note of the external URL.
  2. Go to a different screen and then come back to that video. Make sure the file was loaded from cache. PASS
  3. Now go to a different screen and wait 5 minutes.
  4. Come back to the same video. It should be loaded from the external URL. PASS
3. "Clear cache" button functionality
  1. Go to the video-heavy profile, make note of the external URL.
  2. Go to a different screen and then come back to that video. Make sure the file was loaded from cache. PASS
  3. Now quit the app (to ensure file is not in use when trying to delete it)
  4. Clear cache in settings
  5. Go back to the same video. It should now be loaded from the external URL. PASS

Performance testing
-----------------------

Device: iPhone 13 mini
iOS: 17.3.1
Damus: This commit
Baseline: 87de88861adb3b41d73998452e7c876ab5ee06bf
Setup:
- Debug connection
- Expiry time locally changed to 5 minutes
- Running on Profile mode, with XCode Instruments

Steps:
1. Start recording network activity with XCode Instruments
2. Go to a video-heavy profile (e.g. Julian Figueroa)
3. Scroll down to a specific video (Make sure to scroll through at least 5 videos)
4. Stop recording and measure the "Bytes In" from "Network connections"
5. Repeat this for all test configurations

Results:
- Baseline (No caching support): 26.74 MiB
- This commit (First run, cleared cache): 40.52 MiB
- This commit (Second run, cache filled with videos): 8.13 MiB

Automated test coverage
------------------------

PASS

Device: iPhone 15 simulator
iOS: 17.4
Damus: This commit
Coverage:
- Ran new automated tests multiple times. PASS 3/3 times
- Ran all other automated tests. PASS

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Link: 20240411004129.84436-3-daniel@daquino.me
Signed-off-by: William Casarin <jb55@jb55.com>
2024-04-17 15:06:12 -07:00
..
Assets privacy: add function to strip location data from photos 2024-02-20 11:17:57 -08:00
Mocking home: add quote repost counter and handler 2024-03-17 08:54:35 +00:00
Models mute: adding new structs/enums for new mute list 2024-01-25 12:12:57 -08:00
Util nip42: add initial relay auth support 2024-01-05 10:36:03 -08:00
__Snapshots__/EventViewTests test: Add basic snapshot test coverage for EventView 2023-10-16 03:13:28 +02:00
AuthIntegrationTests.swift test: fix crashing in AUTH test 2024-01-10 15:37:52 -08:00
Bech32ObjectTests.swift nip19: add high level bech32 encoding method 2024-01-16 16:55:31 -08:00
Bech32Tests.swift ndb: switch to nostrdb notes 2023-08-03 13:20:36 -07:00
ContentParserTests.swift content: add utf8 char at url left boundary test 2023-07-16 11:46:23 -07:00
DMTests.swift Fix old notifications always appearing on first start 2023-08-06 09:22:28 -07:00
DamusCacheManagerTests.swift storage: Improve clear cache functionality 2023-10-07 16:42:08 -07:00
DamusPurpleImpendingExpirationTests.swift Add Damus Purple impending expiry notification support 2024-02-28 23:20:48 -08:00
EventGroupViewTests.swift test: attempt to fix broken tests 2023-11-13 15:03:17 -08:00
EventViewTests.swift tests: disable snapshot tests for now 2023-11-14 07:13:51 -08:00
FormatTests.swift Fix localization issues, add tests, import translations, and add zh-CN and zh-TW 2023-02-24 12:44:54 -08:00
HashtagTests.swift Fix Issue #1820 Hashtags including U+5009 to U+500D are not correctly parsed 2023-12-22 13:59:31 -08:00
ImageMetadataTest.swift add performance upgrades to media picker 2024-02-29 12:12:22 +00:00
InvoiceTests.swift Create helper extensions for Block and update tests for the Block helper model 2023-09-03 18:02:32 -07:00
KeychainStorageTests.swift Replace Vault dependency with @KeychainStorage property wrapper 2023-05-04 15:57:02 -07:00
LikeTests.swift ndb: switch to nostrdb notes 2023-08-03 13:20:36 -07:00
ListTests.swift mute: migrate Lists.swift to use new MuteItem 2024-01-25 12:12:59 -08:00
LocalizationUtilTests.swift Fix localization issues and export strings for translation 2023-07-14 09:34:29 -07:00
LongPostTests.swift Merge improved mute functionality from Charlie 2024-02-26 12:02:41 -08:00
NIP19Tests.swift ndb: switch to nostrdb notes 2023-08-03 13:20:36 -07:00
NostrEventTests.swift Fix image links appearing with escaped slashes 2023-08-18 08:41:21 -07:00
NostrScriptTests.swift tests: Disable NostrScriptTests.test_bool_set to reduce noise on CI/CD 2023-12-22 13:56:57 -08:00
NoteContentViewTests.swift nip19: add bech32 TLV url parsing 2024-01-22 10:49:33 -08:00
PostViewTests.swift mentions: fix regression on char handling after mention 2024-01-25 14:11:31 -08:00
ProfileViewTests.swift test: switch test to use failable transactions 2024-01-10 15:38:21 -08:00
RelayPoolTests.swift handle extra slashes for relay url 2023-12-16 17:43:00 -08:00
RelayURLTests.swift Fix relay URL trailing slash issues 2024-03-25 09:24:17 +01:00
ReplyDescriptionTests.swift Add image uploader 2023-03-15 17:12:05 -06:00
ReplyTests.swift test: attempt to fix broken tests 2023-11-13 15:03:17 -08:00
RequestTests.swift nip42: add initial relay auth support 2024-01-05 10:36:03 -08:00
TimeAgoTests.swift Fix localization issues, add tests, import translations, and add zh-CN and zh-TW 2023-02-24 12:44:54 -08:00
TranslationTests.swift translate: implement string distance for close matches 2024-02-19 13:10:13 -08:00
TrieTests.swift Add trie-based user search cache to replace non-performant linear scans 2023-07-03 12:06:01 -07:00
UrlTests.swift purple: add staging option to DamusPurpleURL 2024-01-28 16:09:14 -08:00
UserSearchAppendTests.swift posting: fix issue with username and multiple emojis 2023-09-11 07:48:36 -07:00
UserSearchCacheTests.swift test: temporarily disable UserCacheManagerTests 2023-10-07 14:35:24 -07:00
VideoCacheTests.swift Cache videos 2024-04-17 15:06:12 -07:00
WalletConnectTests.swift Remove no-op performance tests that were causing issues 2024-04-17 15:05:35 -07:00
ZapTests.swift Fix test target build error 2024-01-10 11:06:32 -08:00
damusTests.swift Remove no-op performance tests that were causing issues 2024-04-17 15:05:35 -07:00