Merge branch 'master' into sid-dahiya/JniBuildFix

This commit is contained in:
Max Golovanov 2020-06-25 18:20:13 -07:00 коммит произвёл GitHub
Родитель 3755fe4322 8dcaed7301
Коммит 9c6d0d03f6
2 изменённых файлов: 27 добавлений и 2 удалений

Просмотреть файл

@ -27,7 +27,20 @@ public:
LOG_INFO("=== %s.%s [%s]", test.test_case_name(), test.name(), test.result()->Passed() ? "OK" : "FAILED");
if(!test.result()->Passed())
{
#if 0
// use something like this code after we switch to Xcode 12 and can
// delete the deprecated code in the else block below. ADO 4251996
XCTSourceCodeLocation *location = [[[XCTSourceCodeLocation alloc] initWithFilePath:[NSString stringWithUTF8String:test.file()] lineNumber:test.line()] autorelease];
XCTSourceCodeContext *context = [[[XCTSourceCodeContext alloc] initWithLocation:location] autorelease];
XCTIssue *issue = [[[XCTIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:[NSString stringWithUTF8String:test.test_case_name()] detailedDescription:nil sourceCodeContext:context associatedError:nil attachments:@[]] autorelease];
[m_tests recordIssue:issue];
#else
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[m_tests recordFailureWithDescription:[NSString stringWithUTF8String:test.test_case_name()] inFile:[NSString stringWithUTF8String:test.file()] atLine:test.line() expected:true];
#pragma clang diagnostic pop
#endif
}
}
private:

Просмотреть файл

@ -39,6 +39,7 @@ class TransmissionPolicyManager4Test : public TransmissionPolicyManager {
std::set<EventsUploadContextPtr> const& activeUploads() const { return m_activeUploads; }
EventsUploadContextPtr fakeActiveUpload() { auto ctx = new EventsUploadContext(); ctx->requestedMinLatency = EventLatency_RealTime; m_activeUploads.insert(ctx); return ctx; }
EventsUploadContextPtr fakeActiveUpload(EventLatency latency) { auto ctx = new EventsUploadContext(); ctx->requestedMinLatency = latency; m_activeUploads.insert(ctx); return ctx; }
bool paused() const { return m_isPaused; }
void paused(bool state) { m_isPaused = state; }
@ -46,6 +47,8 @@ class TransmissionPolicyManager4Test : public TransmissionPolicyManager {
int timerDelay() const { return m_timerdelay; }
void timerDelay(int delay) { m_timerdelay = delay; }
void runningLatency(EventLatency latency) { m_runningLatency = latency; }
void NotMockScheduleUpload(int delay, EventLatency latency, bool force)
{
TransmissionPolicyManager::scheduleUpload(delay, latency, force);
@ -279,11 +282,20 @@ TEST_F(TransmissionPolicyManagerTests, UploadInitiatesUpload)
EXPECT_THAT(tpm.activeUploads(), Contains(upload));
}
TEST_F(TransmissionPolicyManagerTests, EmptyUploadReschedulesAtTimerDelay)
TEST_F(TransmissionPolicyManagerTests, EmptyUploadCeasesUploadingForRunningLatencyNormal)
{
auto upload = tpm.fakeActiveUpload(EventLatency_Normal);
EXPECT_CALL(tpm, scheduleUpload(_, _, false))
.Times(0);
tpm.nothingToUpload(upload);
}
TEST_F(TransmissionPolicyManagerTests, EmptyUploadReschedulesAtTimerDelayForRunningLatencyRealtime)
{
auto upload = tpm.fakeActiveUpload();
constexpr std::chrono::duration<int,std::milli> delay { std::chrono::seconds(300) };
tpm.timerDelay(delay.count());
tpm.runningLatency(EventLatency_RealTime);
EXPECT_CALL(tpm, scheduleUpload(delay.count(), EventLatency_Normal, false))
.WillOnce(Return());
tpm.nothingToUpload(upload);