BrowserView163Tests.inc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Round 163 (user feedback): what a Browser shows — hidden roots, the content filter and the saved view of the main
  2. // Browser and of the separate Sample browser window.
  3. #include "core/BrowserView.h"
  4. TEST (browser163_content_filter)
  5. {
  6. using namespace lynx::browserview;
  7. CHECK (listed ("Kick.WAV", ContentFilter::all));
  8. CHECK (listed ("pad.sf2", ContentFilter::all));
  9. CHECK (! listed ("readme.txt", ContentFilter::all));
  10. CHECK (! listed ("noextension", ContentFilter::all));
  11. CHECK (listed ("loop.flac", ContentFilter::audio));
  12. CHECK (! listed ("pad.sf2", ContentFilter::audio));
  13. CHECK (listed ("pad.SF3", ContentFilter::samples));
  14. CHECK (listed ("hat.mp3", ContentFilter::samples));
  15. CHECK (! listed ("beat.flp", ContentFilter::samples));
  16. CHECK (listed ("lead.fst", ContentFilter::presets));
  17. CHECK (! listed ("lead.wav", ContentFilter::presets));
  18. CHECK (listed ("song.lynx", ContentFilter::projects));
  19. CHECK (listed ("song.mid", ContentFilter::projects));
  20. CHECK (! listed ("kick.wav", ContentFilter::projects));
  21. for (int i = 0; i < contentFilterCount; ++i)
  22. CHECK (contentFilterFromId (contentFilterId ((ContentFilter) i)) == (ContentFilter) i);
  23. CHECK (contentFilterFromId ("bogus") == ContentFilter::all);
  24. }
  25. TEST (browser163_view_round_trip)
  26. {
  27. using namespace lynx::browserview;
  28. View v;
  29. CHECK (v.shows ("C:\\Users\\me\\Desktop"));
  30. v.setShown ("C:\\Users\\me\\Desktop", false);
  31. v.setShown (projectRootId, false);
  32. v.filter = ContentFilter::samples;
  33. v.open = true;
  34. v.x = 10; v.y = -20; v.width = 340; v.height = 600;
  35. CHECK (! v.shows ("C:\\Users\\me\\Desktop") && ! v.shows (projectRootId) && v.shows (pluginsRootId));
  36. const auto back = View::fromText (v.toText());
  37. CHECK (back == v);
  38. v.setShown (projectRootId, true);
  39. CHECK (v.shows (projectRootId));
  40. // old / empty files: everything shown, all files
  41. CHECK (View::fromText ("") == View {});
  42. CHECK (View::fromText ("garbage\nfilter=presets\r\nbounds=1,2,x\n").filter == ContentFilter::presets);
  43. CHECK (sampleBrowserShowsByDefault (RootKind::flSamples) && sampleBrowserShowsByDefault (RootKind::user));
  44. CHECK (! sampleBrowserShowsByDefault (RootKind::documents) && ! sampleBrowserShowsByDefault (RootKind::project)
  45. && ! sampleBrowserShowsByDefault (RootKind::flDemos) && ! sampleBrowserShowsByDefault (RootKind::pluginDatabase));
  46. }