Repository: xbmc/xbmc
File: xbmc/cores/VideoPlayer/test/edl/TestEdl.cpp (C++)

Code before:
TEST_F(TestEdl, TestParsingMplayerTimeBasedEDL)
{
  CEdl edl;

  // create a dummy "media" fileitem whose corresponding edl file is testdata/mplayertimebased.edl
  CFileItem mediaItem;
  mediaItem.SetPath(
      XBMC_REF_FILE_PATH("xbmc/cores/VideoPlayer/test/edl/testdata/mplayertimebased.mkv"));
  const bool found = edl.ReadEditDecisionLists(mediaItem, 0);
  // expect kodi to be able to parse the file correctly
  EXPECT_EQ(found, true);
  // the file has 5 interest points: 2 scenemarkers, 1 mute, 1 cut and 1 commbreak
  // edit list should contain any edit that is not a scene marker nor a cut, so 2.
  // scenemarkers should be 4 (two "raw" scene markers and 2 from the commbreak - start and end of commbreaks)
  EXPECT_EQ(edl.HasEdits(), true);
  EXPECT_EQ(edl.HasSceneMarker(), true);
  EXPECT_EQ(edl.GetEditList().size(), 2);
  EXPECT_EQ(edl.GetSceneMarkers().size(), 4);

  // cuts
  // file has only 1 cut starting at 5.3 secs and ending at 7.1 secs
  // so total cut time should be 1.8 seconds (1800 msec)
  EXPECT_EQ(edl.HasCuts(), true);
  EXPECT_EQ(edl.GetTotalCutTime(), 1800ms);
  EXPECT_EQ(edl.GetCutMarkers().size(), 1);
  EXPECT_EQ(edl.GetCutMarkers().at(0), 5300ms); // 5.3 secs
  // When removing or restoring cuts, EDL adds (or removes) 1 msec to jump over the start or end boundary of the edit
  EXPECT_EQ(edl.GetTimeWithoutCuts(edl.GetRawEditList().at(0).start),
            edl.GetRawEditList().at(0).start + 1ms);
  EXPECT_EQ(edl.GetTimeAfterRestoringCuts(edl.GetRawEditList().at(0).start),
            edl.GetRawEditList().at(0).start);
  EXPECT_EQ(edl.GetTimeAfterRestoringCuts(edl.GetRawEditList().at(0).start + 2ms),
            edl.GetRawEditList().at(0).end + 2ms);

  // the first edit (note editlist does not contain cuts) is a mute section starting at 15 seconds
  // of the real file this should correspond to 13.2 secs on the kodi VideoPlayer timeline (start - cuttime)
  // raw edit list contains cuts so mute should be index 1
  const auto mute = edl.GetEditList().at(0);
  const auto muteRaw = edl.GetRawEditList().at(1);
  EXPECT_EQ(mute.action, Action::MUTE);
  EXPECT_EQ(muteRaw.action, Action::MUTE);
  EXPECT_EQ(edl.GetTimeWithoutCuts(mute.start), mute.start - edl.GetTotalCutTime());
  EXPECT_EQ(edl.GetTimeAfterRestoringCuts(mute.start - edl.GetTotalCutTime()), mute.start);
  EXPECT_EQ(muteRaw.start - edl.GetTotalCutTime(), mute.start);
  EXPECT_NE(edl.InEdit(muteRaw.start), std::nullopt);
  EXPECT_EQ(edl.InEdit(mute.start), std::nullopt);

  // scene markers
  // one of the scenemarkers (the first) have start and end times defined, kodi should assume the marker at the END position (255.3 secs)
  EXPECT_EQ(edl.GetSceneMarkers().at(0),
            edl.GetTimeWithoutCuts(duration_cast<std::chrono::milliseconds>(255.3s)));

Review comment (suggestion):
Should there be an include in this file now?

```
 #include <chrono>
```

Code after:
};

TEST_F(TestEdl, TestParsingMplayerTimeBasedEDL)
{
  CEdl edl;

  // create a dummy "media" fileitem whose corresponding edl file is testdata/mplayertimebased.edl
  CFileItem mediaItem;
  mediaItem.SetPath(
      XBMC_REF_FILE_PATH("xbmc/cores/VideoPlayer/test/edl/testdata/mplayertimebased.mkv"));
  const bool found = edl.ReadEditDecisionLists(mediaItem, 0);
  // expect kodi to be able to parse the file correctly
  EXPECT_EQ(found, true);
  // the file has 5 interest points: 2 scenemarkers, 1 mute, 1 cut and 1 commbreak
  // edit list should contain any edit that is not a scene marker nor a cut, so 2.
  // scenemarkers should be 4 (two "raw" scene markers and 2 from the commbreak - start and end of commbreaks)
  EXPECT_EQ(edl.HasEdits(), true);
  EXPECT_EQ(edl.HasSceneMarker(), true);
  EXPECT_EQ(edl.GetEditList().size(), 2);
  EXPECT_EQ(edl.GetSceneMarkers().size(), 4);

  // cuts
  // file has only 1 cut starting at 5.3 secs and ending at 7.1 secs
  // so total cut time should be 1.8 seconds (1800 msec)
  EXPECT_EQ(edl.HasCuts(), true);
  EXPECT_EQ(edl.GetTotalCutTime(), 1800ms);
  EXPECT_EQ(edl.GetCutMarkers().size(), 1);
  EXPECT_EQ(edl.GetCutMarkers().at(0), 5300ms);
  // When removing or restoring cuts, EDL adds (or removes) 1 msec to jump over the start or end boundary of the edit
  EXPECT_EQ(edl.GetTimeWithoutCuts(edl.GetRawEditList().at(0).start),
            edl.GetRawEditList().at(0).start + 1ms);
  EXPECT_EQ(edl.GetTimeAfterRestoringCuts(edl.GetRawEditList().at(0).start),
            edl.GetRawEditList().at(0).start);
  EXPECT_EQ(edl.GetTimeAfterRestoringCuts(edl.GetRawEditList().at(0).start + 2ms),
            edl.GetRawEditList().at(0).end + 2ms);

  // the first edit (note editlist does not contain cuts) is a mute section starting at 15 seconds
  // of the real file this should correspond to 13.2 secs on the kodi VideoPlayer timeline (start - cuttime)
  // raw edit list contains cuts so mute should be index 1
  const auto mute = edl.GetEditList().at(0);
  const auto muteRaw = edl.GetRawEditList().at(1);
  EXPECT_EQ(mute.action, Action::MUTE);
  EXPECT_EQ(muteRaw.action, Action::MUTE);
  EXPECT_EQ(edl.GetTimeWithoutCuts(mute.start), mute.start - edl.GetTotalCutTime());
  EXPECT_EQ(edl.GetTimeAfterRestoringCuts(mute.start - edl.GetTotalCutTime()), mute.start);
  EXPECT_EQ(muteRaw.start - edl.GetTotalCutTime(), mute.start);
  EXPECT_NE(edl.InEdit(muteRaw.start), std::nullopt);
  EXPECT_EQ(edl.InEdit(mute.start), std::nullopt);

  // scene markers
  // one of the scenemarkers (the first) have start and end times defined, kodi should assume the marker at the END position (255.3 secs)