@Test
public void testCaptureFilterFeatureTrack() throws InterruptedException, IOException {

  final FakeFeatureTracker tracker = (FakeFeatureTracker)myServices.getFeatureTracker();
  // Capture a trace to apply filter on.
  CpuProfilerTestUtils
    .captureSuccessfully(myStage, myCpuService, myTransportService, CpuProfilerTestUtils.readValidTrace());
  FilterModel filterModel = new FilterModel();
  Filter filter = Filter.EMPTY_FILTER;
  filterModel.setFilter(filter);
  myStage.applyCaptureFilter(filter);
  FilterMetadata filterMetadata = tracker.getLastFilterMetadata();
  assertThat(filterMetadata).isNotNull();
  assertThat(filterMetadata.getFilterTextLength()).isEqualTo(0);
  assertThat(filterMetadata.getFeaturesUsed()).isEqualTo(0);
  // Test with some filter features and non empty text
  filter = new Filter("some", true, true);
  filterModel.setFilter(filter);
  myStage.applyCaptureFilter(filter);
  filterMetadata = tracker.getLastFilterMetadata();
  assertThat(filterMetadata).isNotNull();
  assertThat(filterMetadata.getFilterTextLength()).isEqualTo(4);
  assertThat(filterMetadata.getFeaturesUsed()).isEqualTo(FilterMetadata.MATCH_CASE | FilterMetadata.IS_REGEX);
}