Lines Matching refs:payload_state

69                                        PayloadState* payload_state,  in SetupPayloadStateWith2Urls()  argument
79 payload_state->SetResponse(*response); in SetupPayloadStateWith2Urls()
80 string stored_response_sign = payload_state->GetResponseSignature(); in SetupPayloadStateWith2Urls()
135 PayloadState payload_state; in TEST() local
136 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
137 payload_state.SetResponse(response); in TEST()
138 string stored_response_sign = payload_state.GetResponseSignature(); in TEST()
143 EXPECT_EQ("", payload_state.GetCurrentUrl()); in TEST()
144 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
145 EXPECT_EQ(0U, payload_state.GetUrlSwitchCount()); in TEST()
146 EXPECT_EQ(1, payload_state.GetNumResponsesSeen()); in TEST()
178 PayloadState payload_state; in TEST() local
179 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
180 payload_state.SetResponse(response); in TEST()
181 string stored_response_sign = payload_state.GetResponseSignature(); in TEST()
194 EXPECT_EQ("https://single.url.test", payload_state.GetCurrentUrl()); in TEST()
195 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
196 EXPECT_EQ(0U, payload_state.GetUrlSwitchCount()); in TEST()
197 EXPECT_EQ(1, payload_state.GetNumResponsesSeen()); in TEST()
227 PayloadState payload_state; in TEST() local
228 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
229 payload_state.SetResponse(response); in TEST()
230 string stored_response_sign = payload_state.GetResponseSignature(); in TEST()
244 EXPECT_EQ("http://multiple.url.test", payload_state.GetCurrentUrl()); in TEST()
245 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
246 EXPECT_EQ(0U, payload_state.GetUrlSwitchCount()); in TEST()
247 EXPECT_EQ(1, payload_state.GetNumResponsesSeen()); in TEST()
254 PayloadState payload_state; in TEST() local
280 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
285 "Hash1235", true, false, &payload_state, &response); in TEST()
286 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
290 payload_state.UpdateFailed(error); in TEST()
291 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
294 payload_state.UpdateFailed(error); in TEST()
295 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
298 payload_state.UpdateFailed(error); in TEST()
299 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
302 EXPECT_EQ(3U, payload_state.GetUrlSwitchCount()); in TEST()
308 PayloadState payload_state; in TEST() local
310 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
314 "Hash5823", true, false, &payload_state, &response); in TEST()
315 EXPECT_EQ(1, payload_state.GetNumResponsesSeen()); in TEST()
319 payload_state.UpdateFailed(error); in TEST()
320 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
321 EXPECT_EQ(1U, payload_state.GetUrlSwitchCount()); in TEST()
325 "Hash8225", true, false, &payload_state, &response); in TEST()
326 EXPECT_EQ(2, payload_state.GetNumResponsesSeen()); in TEST()
329 payload_state.UpdateFailed(error); in TEST()
330 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
331 EXPECT_EQ(1U, payload_state.GetUrlSwitchCount()); in TEST()
335 "Hash9999", true, false, &payload_state, &response); in TEST()
336 EXPECT_EQ(3, payload_state.GetNumResponsesSeen()); in TEST()
339 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
340 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
341 EXPECT_EQ(0U, payload_state.GetUrlSwitchCount()); in TEST()
343 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
345 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
347 0U, payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
349 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
354 PayloadState payload_state; in TEST() local
403 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
406 "Hash5873", true, false, &payload_state, &response); in TEST()
407 EXPECT_EQ(1, payload_state.GetNumResponsesSeen()); in TEST()
410 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch); in TEST()
411 EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber()); in TEST()
412 EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber()); in TEST()
413 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
414 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
415 EXPECT_EQ(1U, payload_state.GetUrlSwitchCount()); in TEST()
418 payload_state.UpdateFailed(ErrorCode::kDownloadTransferError); in TEST()
419 EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber()); in TEST()
420 EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber()); in TEST()
421 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
422 EXPECT_EQ(1U, payload_state.GetUrlFailureCount()); in TEST()
423 EXPECT_EQ(1U, payload_state.GetUrlSwitchCount()); in TEST()
426 payload_state.UpdateFailed(ErrorCode::kDownloadTransferError); in TEST()
427 EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber()); in TEST()
428 EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber()); in TEST()
429 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
430 EXPECT_EQ(2U, payload_state.GetUrlFailureCount()); in TEST()
431 EXPECT_EQ(1U, payload_state.GetUrlSwitchCount()); in TEST()
437 payload_state.UpdateFailed(ErrorCode::kDownloadTransferError); in TEST()
438 EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber()); in TEST()
439 EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber()); in TEST()
440 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
441 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
442 EXPECT_EQ(2U, payload_state.GetUrlSwitchCount()); in TEST()
443 EXPECT_TRUE(payload_state.ShouldBackoffDownload()); in TEST()
446 payload_state.UpdateFailed(ErrorCode::kPayloadHashMismatchError); in TEST()
447 EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber()); in TEST()
448 EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber()); in TEST()
449 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
450 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
451 EXPECT_EQ(3U, payload_state.GetUrlSwitchCount()); in TEST()
452 EXPECT_TRUE(payload_state.ShouldBackoffDownload()); in TEST()
456 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMissingError); in TEST()
457 EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber()); in TEST()
458 EXPECT_EQ(2, payload_state.GetFullPayloadAttemptNumber()); in TEST()
459 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
460 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
461 EXPECT_EQ(4U, payload_state.GetUrlSwitchCount()); in TEST()
462 EXPECT_TRUE(payload_state.ShouldBackoffDownload()); in TEST()
465 payload_state.UpdateFailed(static_cast<ErrorCode>( in TEST()
467 EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber()); in TEST()
468 EXPECT_EQ(2, payload_state.GetFullPayloadAttemptNumber()); in TEST()
469 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
470 EXPECT_EQ(1U, payload_state.GetUrlFailureCount()); in TEST()
471 EXPECT_EQ(4U, payload_state.GetUrlSwitchCount()); in TEST()
472 EXPECT_TRUE(payload_state.ShouldBackoffDownload()); in TEST()
476 payload_state.DownloadProgress(progress_bytes); in TEST()
477 EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber()); in TEST()
478 EXPECT_EQ(2, payload_state.GetFullPayloadAttemptNumber()); in TEST()
479 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
480 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
481 EXPECT_EQ(4U, payload_state.GetUrlSwitchCount()); in TEST()
482 EXPECT_TRUE(payload_state.ShouldBackoffDownload()); in TEST()
486 "Hash8532", true, false, &payload_state, &response); in TEST()
487 EXPECT_EQ(2, payload_state.GetNumResponsesSeen()); in TEST()
490 EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber()); in TEST()
491 EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber()); in TEST()
492 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
493 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
494 EXPECT_EQ(0U, payload_state.GetUrlSwitchCount()); in TEST()
495 EXPECT_FALSE(payload_state.ShouldBackoffDownload()); in TEST()
500 PayloadState payload_state; in TEST() local
521 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
524 "Hash8593", true, false, &payload_state, &response); in TEST()
527 EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber()); in TEST()
528 EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber()); in TEST()
529 payload_state.DownloadComplete(); in TEST()
530 EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber()); in TEST()
531 EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber()); in TEST()
532 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
533 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
534 EXPECT_EQ(0U, payload_state.GetUrlSwitchCount()); in TEST()
539 PayloadState payload_state; in TEST() local
559 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
561 SetupPayloadStateWith2Urls("Hash8593", true, true, &payload_state, &response); in TEST()
564 EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber()); in TEST()
565 EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber()); in TEST()
566 payload_state.DownloadComplete(); in TEST()
567 EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber()); in TEST()
568 EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber()); in TEST()
569 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
570 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
571 EXPECT_EQ(0U, payload_state.GetUrlSwitchCount()); in TEST()
576 PayloadState payload_state; in TEST() local
579 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
581 "Hash4427", true, false, &payload_state, &response); in TEST()
585 payload_state.DownloadComplete(); in TEST()
586 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch); in TEST()
587 payload_state.UpdateFailed(ErrorCode::kDownloadTransferError); in TEST()
588 EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber()); in TEST()
589 EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber()); in TEST()
590 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
591 EXPECT_EQ(1U, payload_state.GetUrlFailureCount()); in TEST()
592 EXPECT_EQ(1U, payload_state.GetUrlSwitchCount()); in TEST()
615 EXPECT_TRUE(payload_state.Initialize(&fake_system_state2)); in TEST()
617 "Hash4427", true, false, &payload_state, &response); in TEST()
621 EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber()); in TEST()
622 EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber()); in TEST()
623 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
624 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
625 EXPECT_EQ(0U, payload_state.GetUrlSwitchCount()); in TEST()
630 PayloadState payload_state; in TEST() local
636 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
638 "Hash6437", true, false, &payload_state, &response); in TEST()
643 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch); in TEST()
644 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch); in TEST()
645 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
646 EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber()); in TEST()
647 EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber()); in TEST()
648 EXPECT_FALSE(payload_state.ShouldBackoffDownload()); in TEST()
653 PayloadState payload_state; in TEST() local
659 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
661 "Hash6437", true, false, &payload_state, &response); in TEST()
666 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch); in TEST()
667 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch); in TEST()
668 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
669 EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber()); in TEST()
670 EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber()); in TEST()
672 payload_state.SetUsingP2PForDownloading(true); in TEST()
673 payload_state.SetP2PUrl("http://mypeer:52909/path/to/file"); in TEST()
675 EXPECT_FALSE(payload_state.ShouldBackoffDownload()); in TEST()
677 payload_state.SetP2PUrl(""); in TEST()
679 EXPECT_TRUE(payload_state.ShouldBackoffDownload()); in TEST()
684 PayloadState payload_state; in TEST() local
687 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
688 SetupPayloadStateWith2Urls("Hash6437", true, true, &payload_state, &response); in TEST()
692 payload_state.DownloadComplete(); in TEST()
693 EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber()); in TEST()
694 EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber()); in TEST()
695 EXPECT_FALSE(payload_state.ShouldBackoffDownload()); in TEST()
700 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch); in TEST()
701 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch); in TEST()
702 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
703 EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber()); in TEST()
704 EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber()); in TEST()
705 EXPECT_FALSE(payload_state.ShouldBackoffDownload()); in TEST()
708 static void CheckPayloadBackoffState(PayloadState* payload_state, in CheckPayloadBackoffState() argument
711 payload_state->DownloadComplete(); in CheckPayloadBackoffState()
713 payload_state->GetFullPayloadAttemptNumber()); in CheckPayloadBackoffState()
714 EXPECT_TRUE(payload_state->ShouldBackoffDownload()); in CheckPayloadBackoffState()
715 Time backoff_expiry_time = payload_state->GetBackoffExpiryTime(); in CheckPayloadBackoffState()
728 PayloadState payload_state; in TEST() local
731 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
733 "Hash8939", true, false, &payload_state, &response); in TEST()
735 CheckPayloadBackoffState(&payload_state, 1, TimeDelta::FromDays(1)); in TEST()
736 CheckPayloadBackoffState(&payload_state, 2, TimeDelta::FromDays(2)); in TEST()
737 CheckPayloadBackoffState(&payload_state, 3, TimeDelta::FromDays(4)); in TEST()
738 CheckPayloadBackoffState(&payload_state, 4, TimeDelta::FromDays(8)); in TEST()
739 CheckPayloadBackoffState(&payload_state, 5, TimeDelta::FromDays(16)); in TEST()
740 CheckPayloadBackoffState(&payload_state, 6, TimeDelta::FromDays(16)); in TEST()
741 CheckPayloadBackoffState(&payload_state, 7, TimeDelta::FromDays(16)); in TEST()
742 CheckPayloadBackoffState(&payload_state, 8, TimeDelta::FromDays(16)); in TEST()
743 CheckPayloadBackoffState(&payload_state, 9, TimeDelta::FromDays(16)); in TEST()
744 CheckPayloadBackoffState(&payload_state, 10, TimeDelta::FromDays(16)); in TEST()
750 PayloadState payload_state; in TEST() local
753 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
755 "Hash8939", true, false, &payload_state, &response); in TEST()
759 payload_state.DownloadComplete(); in TEST()
760 EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber()); in TEST()
761 EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber()); in TEST()
762 EXPECT_FALSE(payload_state.ShouldBackoffDownload()); in TEST()
767 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch); in TEST()
768 payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch); in TEST()
769 EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber()); in TEST()
770 EXPECT_EQ(2, payload_state.GetFullPayloadAttemptNumber()); in TEST()
771 EXPECT_FALSE(payload_state.ShouldBackoffDownload()); in TEST()
777 PayloadState payload_state; in TEST() local
782 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
784 "Hash3286", true, false, &payload_state, &response); in TEST()
785 EXPECT_EQ(1, payload_state.GetNumResponsesSeen()); in TEST()
791 payload_state.DownloadProgress(prev_chunk); in TEST()
795 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
797 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
802 "Hash9904", true, false, &payload_state, &response); in TEST()
803 EXPECT_EQ(2, payload_state.GetNumResponsesSeen()); in TEST()
808 payload_state.DownloadProgress(first_chunk); in TEST()
811 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
813 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
815 0U, payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
817 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
821 payload_state.UpdateFailed(error); in TEST()
826 payload_state.DownloadProgress(second_chunk); in TEST()
828 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
830 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
833 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
835 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
838 payload_state.UpdateFailed(error); in TEST()
842 payload_state.DownloadProgress(third_chunk); in TEST()
846 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
848 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
851 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
853 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
857 payload_state.UpdateFailed(error); in TEST()
858 payload_state.SetUsingP2PForDownloading(true); in TEST()
860 payload_state.DownloadProgress(p2p_total); in TEST()
863 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpPeer)); in TEST()
869 payload_state.UpdateSucceeded(); in TEST()
873 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
875 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
877 0U, payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
879 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
880 EXPECT_EQ(0, payload_state.GetNumResponsesSeen()); in TEST()
885 PayloadState payload_state; in TEST() local
888 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
890 "Hash3286", true, false, &payload_state, &response); in TEST()
894 payload_state.DownloadProgress(num_bytes); in TEST()
898 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
900 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
920 payload_state.UpdateSucceeded(); in TEST()
926 PayloadState payload_state; in TEST() local
928 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
932 "Hash5823", true, false, &payload_state, &response); in TEST()
935 payload_state.DownloadProgress(num_bytes); in TEST()
937 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
939 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
941 0U, payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
943 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpsServer)); in TEST()
945 payload_state.UpdateRestarted(); in TEST()
948 payload_state.GetCurrentBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
950 payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpServer)); in TEST()
955 PayloadState payload_state; in TEST() local
961 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
963 payload_state.UpdateRestarted(); in TEST()
964 EXPECT_EQ(0U, payload_state.GetNumReboots()); in TEST()
967 payload_state.UpdateResumed(); in TEST()
969 EXPECT_EQ(1U, payload_state.GetNumReboots()); in TEST()
972 payload_state.UpdateResumed(); in TEST()
974 EXPECT_EQ(1U, payload_state.GetNumReboots()); in TEST()
977 payload_state.UpdateRestarted(); in TEST()
978 EXPECT_EQ(0U, payload_state.GetNumReboots()); in TEST()
983 PayloadState payload_state; in TEST() local
987 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
990 EXPECT_FALSE(payload_state.GetRollbackHappened()); in TEST()
995 payload_state.SetRollbackHappened(true); in TEST()
996 EXPECT_TRUE(payload_state.GetRollbackHappened()); in TEST()
1000 payload_state.SetRollbackHappened(false); in TEST()
1001 EXPECT_FALSE(payload_state.GetRollbackHappened()); in TEST()
1008 payload_state.LoadRollbackHappened(); in TEST()
1009 EXPECT_TRUE(payload_state.GetRollbackHappened()); in TEST()
1014 PayloadState payload_state; in TEST() local
1025 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1028 EXPECT_TRUE(payload_state.GetRollbackVersion().empty()); in TEST()
1032 payload_state.Rollback(); in TEST()
1034 EXPECT_EQ(rollback_version, payload_state.GetRollbackVersion()); in TEST()
1043 payload_state.LoadRollbackVersion(); in TEST()
1044 EXPECT_EQ(rollback_version, payload_state.GetRollbackVersion()); in TEST()
1052 payload_state.UpdateSucceeded(); in TEST()
1058 PayloadState payload_state; in TEST() local
1070 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1076 "Hash8593", true, false, &payload_state, &response); in TEST()
1079 payload_state.UpdateSucceeded(); in TEST()
1080 EXPECT_EQ(payload_state.GetUpdateDuration().InMicroseconds(), 7000000); in TEST()
1081 EXPECT_EQ(payload_state.GetUpdateDurationUptime().InMicroseconds(), 4000000); in TEST()
1085 "Hash8594", true, false, &payload_state, &response); in TEST()
1086 EXPECT_EQ(payload_state.GetUpdateDuration().InMicroseconds(), 0); in TEST()
1087 EXPECT_EQ(payload_state.GetUpdateDurationUptime().InMicroseconds(), 0); in TEST()
1093 payload_state.DownloadProgress(10); in TEST()
1094 EXPECT_EQ(payload_state.GetUpdateDuration().InMicroseconds(), 10000000); in TEST()
1095 EXPECT_EQ(payload_state.GetUpdateDurationUptime().InMicroseconds(), 10000000); in TEST()
1120 PayloadState payload_state; in TEST() local
1131 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1135 "Hash8593", true, false, &payload_state, &response); in TEST()
1136 payload_state.UpdateSucceeded(); in TEST()
1162 PayloadState payload_state; in TEST() local
1168 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1183 payload_state.UpdateEngineStarted(); in TEST()
1187 PayloadState payload_state; in TEST() local
1191 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1195 payload_state.UpdateEngineStarted(); in TEST()
1199 PayloadState payload_state; in TEST() local
1208 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1213 payload_state.UpdateEngineStarted(); in TEST()
1219 PayloadState payload_state; in TEST() local
1227 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1230 payload_state.SetResponse(response); in TEST()
1239 payload_state.UpdateRestarted(); in TEST()
1244 payload_state.UpdateSucceeded(); in TEST()
1253 PayloadState payload_state; in TEST() local
1257 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1265 "Hash8433", true, false, &payload_state, &response); in TEST()
1269 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
1277 "Hash8433", false, false, &payload_state, &response); in TEST()
1280 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
1284 payload_state.UpdateFailed(error); in TEST()
1287 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
1288 EXPECT_EQ(0U, payload_state.GetUrlSwitchCount()); in TEST()
1292 "Hash2399", false, false, &payload_state, &response); in TEST()
1295 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
1309 "Hash2399", true, false, &payload_state, &response); in TEST()
1312 EXPECT_EQ("http://test", payload_state.GetCurrentUrl()); in TEST()
1313 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
1317 payload_state.UpdateFailed(error); in TEST()
1318 EXPECT_EQ("https://test", payload_state.GetCurrentUrl()); in TEST()
1319 EXPECT_EQ(1U, payload_state.GetUrlSwitchCount()); in TEST()
1320 EXPECT_EQ(0U, payload_state.GetUrlFailureCount()); in TEST()
1325 PayloadState payload_state; in TEST() local
1328 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1329 SetupPayloadStateWith2Urls("Hash6437", true, true, &payload_state, &response); in TEST()
1332 payload_state.DownloadComplete(); in TEST()
1336 payload_state.UpdateSucceeded(); in TEST()
1344 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1345 SetupPayloadStateWith2Urls("Hash6437", true, true, &payload_state, &response); in TEST()
1347 payload_state.DownloadComplete(); in TEST()
1352 payload_state.UpdateSucceeded(); in TEST()
1357 PayloadState payload_state; in TEST() local
1365 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1367 "Hash6437", true, false, &payload_state, &response); in TEST()
1370 payload_state.DownloadComplete(); in TEST()
1375 payload_state.UpdateSucceeded(); in TEST()
1380 PayloadState payload_state; in TEST() local
1383 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1385 "Hash6437", true, false, &payload_state, &response); in TEST()
1394 payload_state.DownloadComplete(); in TEST()
1399 payload_state.UpdateSucceeded(); in TEST()
1405 PayloadState payload_state; in TEST() local
1409 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1411 "Hash3141", true, false, &payload_state, &response); in TEST()
1414 payload_state.DownloadComplete(); in TEST()
1415 payload_state.UpdateSucceeded(); in TEST()
1416 payload_state.ExpectRebootInNewVersion("Version:12345678"); in TEST()
1421 payload_state.ReportFailedBootIfNeeded(); in TEST()
1426 payload_state.ExpectRebootInNewVersion("Version:12345678"); in TEST()
1430 payload_state.ReportFailedBootIfNeeded(); in TEST()
1435 payload_state.ExpectRebootInNewVersion("Version:3141592"); in TEST()
1438 payload_state.ReportFailedBootIfNeeded(); in TEST()
1445 PayloadState payload_state; in TEST() local
1452 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1454 "Hash3141", true, false, &payload_state, &response); in TEST()
1457 payload_state.DownloadComplete(); in TEST()
1458 payload_state.UpdateSucceeded(); in TEST()
1459 payload_state.ExpectRebootInNewVersion("Version:12345678"); in TEST()
1467 payload_state.ReportFailedBootIfNeeded(); in TEST()
1470 payload_state.ReportFailedBootIfNeeded(); in TEST()
1472 payload_state.ReportFailedBootIfNeeded(); in TEST()
1478 PayloadState payload_state; in TEST() local
1482 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1484 "Hash3141", true, false, &payload_state, &response); in TEST()
1487 payload_state.DownloadComplete(); in TEST()
1488 payload_state.UpdateSucceeded(); in TEST()
1489 payload_state.ExpectRebootInNewVersion("Version:12345678"); in TEST()
1496 payload_state.ResetUpdateStatus(); in TEST()
1499 payload_state.ReportFailedBootIfNeeded(); in TEST()
1504 PayloadState payload_state; in TEST() local
1508 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1515 payload_state.ReportFailedBootIfNeeded(); in TEST()
1520 PayloadState payload_state; in TEST() local
1525 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1527 "Hash8593", true, false, &payload_state, &response); in TEST()
1531 payload_state.P2PNewAttempt(); in TEST()
1532 EXPECT_TRUE(payload_state.P2PAttemptAllowed()); in TEST()
1535 payload_state.P2PNewAttempt(); in TEST()
1536 EXPECT_FALSE(payload_state.P2PAttemptAllowed()); in TEST()
1541 PayloadState payload_state; in TEST() local
1548 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1550 "Hash8593", true, false, &payload_state, &response); in TEST()
1557 payload_state.P2PNewAttempt(); in TEST()
1560 EXPECT_EQ(epoch, payload_state.GetP2PFirstAttemptTimestamp()); in TEST()
1563 EXPECT_TRUE(payload_state.P2PAttemptAllowed()); in TEST()
1568 EXPECT_TRUE(payload_state.P2PAttemptAllowed()); in TEST()
1572 EXPECT_EQ(epoch, payload_state.GetP2PFirstAttemptTimestamp()); in TEST()
1577 EXPECT_TRUE(payload_state.P2PAttemptAllowed()); in TEST()
1582 EXPECT_FALSE(payload_state.P2PAttemptAllowed()); in TEST()
1587 PayloadState payload_state; in TEST() local
1592 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1594 "Hash8593", true, false, &payload_state, &response); in TEST()
1597 EXPECT_EQ(null_time, payload_state.GetP2PFirstAttemptTimestamp()); in TEST()
1598 EXPECT_EQ(0, payload_state.GetP2PNumAttempts()); in TEST()
1603 PayloadState payload_state; in TEST() local
1609 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1611 "Hash8593", true, false, &payload_state, &response); in TEST()
1618 payload_state.P2PNewAttempt(); in TEST()
1619 EXPECT_EQ(1, payload_state.GetP2PNumAttempts()); in TEST()
1620 EXPECT_EQ(time, payload_state.GetP2PFirstAttemptTimestamp()); in TEST()
1632 PayloadState payload_state; in TEST() local
1639 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1641 "Hash8593", true, false, &payload_state, &response); in TEST()
1648 payload_state.P2PNewAttempt(); in TEST()
1649 EXPECT_EQ(1, payload_state.GetP2PNumAttempts()); in TEST()
1650 EXPECT_EQ(time, payload_state.GetP2PFirstAttemptTimestamp()); in TEST()
1654 "Hash9904", true, false, &payload_state, &response); in TEST()
1658 EXPECT_EQ(0, payload_state.GetP2PNumAttempts()); in TEST()
1659 EXPECT_EQ(null_time, payload_state.GetP2PFirstAttemptTimestamp()); in TEST()
1663 PayloadState payload_state; in TEST() local
1668 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1682 payload_state.SetResponse(response); in TEST()
1684 EXPECT_EQ(payload_state.GetCurrentUrl(), "http://test1a"); in TEST()
1685 payload_state.IncrementUrlIndex(); in TEST()
1686 EXPECT_EQ(payload_state.GetCurrentUrl(), "http://test2a"); in TEST()
1688 EXPECT_TRUE(payload_state.NextPayload()); in TEST()
1689 EXPECT_EQ(payload_state.GetCurrentUrl(), "http://test1b"); in TEST()
1693 PayloadState payload_state; in TEST() local
1698 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1708 payload_state.SetResponse(response); in TEST()
1711 payload_state.ExcludeCurrentPayload(); in TEST()
1715 PayloadState payload_state; in TEST() local
1720 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1730 payload_state.SetResponse(response); in TEST()
1734 payload_state.ExcludeCurrentPayload(); in TEST()
1738 PayloadState payload_state; in TEST() local
1743 EXPECT_TRUE(payload_state.Initialize(&fake_system_state)); in TEST()
1763 payload_state.SetResponse(response); in TEST()
1767 payload_state.IncrementFailureCount(); in TEST()
1768 payload_state.IncrementFailureCount(); in TEST()
1770 EXPECT_TRUE(payload_state.NextPayload()); in TEST()
1773 payload_state.IncrementFailureCount(); in TEST()
1778 payload_state.IncrementFailureCount(); in TEST()