testcase/media: add utc for setDuration
add utc for setDuration
@@ -378,6 +378,32 @@ static long get_file_size()
}
static void utc_media_MediaRecorder_setDuration_p(void)
+{
+ {
+ long size;
+ MediaRecorder mr;
+ unique_ptr<FileOutputDataSource> dataSource = unique_ptr<FileOutputDataSource>(new FileOutputDataSource(channels, sampleRate, pcmFormat, filePath));
+
+ auto observer = std::make_shared<RecorderTest>();
+ mr.create();
+ mr.setObserver(observer);
+ mr.setDataSource(std::move(dataSource));
+
+ TC_ASSERT_EQ("utc_media_MediaRecorder_setDuration", mr.setFileSize(0), RECORDER_OK);
+ TC_ASSERT_EQ("utc_media_MediaRecorder_setDuration", mr.setFileSize(-1), RECORDER_OK);
+
+ size = channels * sampleRate * RECORD_DURATION * 2;
+ TC_ASSERT_EQ("utc_media_MediaRecorder_setDuration", mr.setFileSize(size), RECORDER_OK);
+ TC_ASSERT_EQ("utc_media_MediaRecorder_setDuration", mr.prepare(), RECORDER_OK);
+ mr.start();
+ sleep(RECORD_DURATION + 1);
+ mr.stop();
+ mr.unprepare();
+ mr.destroy();
+
+ TC_ASSERT_EQ("utc_media_MediaRecorder_setDuration", get_file_size(), size);
+ }
+
{
long size;
MediaRecorder mr;
@@ -416,12 +442,31 @@ static void utc_media_MediaRecorder_setDuration_p(void)
break;
}
TC_ASSERT_EQ("utc_media_MediaRecorder_setDuration", get_file_size(), size);
+ }
TC_SUCCESS_RESULT();
}
static void utc_media_MediaRecorder_setDuration_n(void)
{
+ {
+ long size;
+ MediaRecorder mr;
+ unique_ptr<FileOutputDataSource> dataSource = unique_ptr<FileOutputDataSource>(new FileOutputDataSource(channels, sampleRate, pcmFormat, filePath));
+ auto observer = std::make_shared<RecorderTest>();
+
+ size = channels * sampleRate * RECORD_DURATION * 2;
+ TC_ASSERT_NEQ("utc_media_MediaRecorder_setDuration", mr.setFileSize(size), RECORDER_OK);
+ mr.create();
+ mr.setObserver(observer);
+ mr.setDataSource(std::move(dataSource));
+
+ TC_ASSERT_EQ("utc_media_MediaRecorder_setDuration", mr.setFileSize(size), RECORDER_OK);
+ mr.destroy();
+
+ TC_ASSERT_EQ("utc_media_MediaRecorder_setDuration", get_file_size(), size);
+ }
+
/* setDuration before create */
{
MediaRecorder mr;
