~michael-sheldon/ubuntu-download-manager/fix-1557771

« back to all changes in this revision

Viewing changes to tests/downloads/daemon/test_download.cpp

  • Committer: CI Train Bot
  • Author(s): Michael Sheldon
  • Date: 2016-03-08 17:45:57 UTC
  • mfrom: (347.3.2 implement-per-app-queueing)
  • Revision ID: ci-train-bot@canonical.com-20160308174557-1p5az22r7usysv5x
Implement per-app queueing instead of having one global queue for all apps
Approved by: Ken VanDine, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1277
1277
        .Times(1)
1278
1278
        .WillOnce(Return(true));
1279
1279
 
 
1280
    EXPECT_CALL(*file, flush())
 
1281
        .Times(1)
 
1282
        .WillOnce(Return(true));
 
1283
 
1280
1284
    EXPECT_CALL(*file, remove())
1281
1285
        .Times(0);
1282
1286
 
1358
1362
        .Times(1)
1359
1363
        .WillOnce(Return(nullptr));
1360
1364
 
 
1365
    EXPECT_CALL(*file, flush())
 
1366
        .Times(1)
 
1367
        .WillOnce(Return(true));
1361
1368
 
1362
1369
    EXPECT_CALL(*_cryptoFactory, createCryptographicHash(_, _))
1363
1370
        .Times(1)
1443
1450
    EXPECT_CALL(*file, reset())
1444
1451
        .Times(1);
1445
1452
 
 
1453
    EXPECT_CALL(*file, flush())
 
1454
        .Times(1)
 
1455
        .WillOnce(Return(true));
 
1456
 
1446
1457
    EXPECT_CALL(*file, remove())
1447
1458
        .Times(0);
1448
1459
 
2057
2068
    EXPECT_CALL(*file, open(QIODevice::ReadWrite | QFile::Append))
2058
2069
        .Times(1)
2059
2070
        .WillOnce(Return(true));
2060
 
 
 
2071
    
2061
2072
    EXPECT_CALL(*file, remove())
2062
2073
        .Times(0);
2063
2074
 
2163
2174
        .Times(1)
2164
2175
        .WillOnce(Return(true));
2165
2176
 
 
2177
    EXPECT_CALL(*file, flush())
 
2178
        .Times(1)
 
2179
        .WillOnce(Return(true));
 
2180
 
2166
2181
    EXPECT_CALL(*file.data(), remove())
2167
2182
        .Times(1)
2168
2183
        .WillOnce(Return(true));
2276
2291
        .Times(1)
2277
2292
        .WillOnce(Return(true));
2278
2293
 
 
2294
    EXPECT_CALL(*file, flush())
 
2295
        .Times(1)
 
2296
        .WillOnce(Return(true));
 
2297
 
2279
2298
    EXPECT_CALL(*file.data(), remove())
2280
2299
        .Times(1)
2281
2300
        .WillOnce(Return(true));
2390
2409
        .Times(1)
2391
2410
        .WillOnce(Return(true));
2392
2411
 
 
2412
    EXPECT_CALL(*file, flush())
 
2413
        .Times(1)
 
2414
        .WillOnce(Return(true));
 
2415
 
2393
2416
    EXPECT_CALL(*file.data(), remove())
2394
2417
        .Times(1)
2395
2418
        .WillOnce(Return(true));
2486
2509
        .Times(1)
2487
2510
        .WillOnce(Return(true));
2488
2511
 
 
2512
    EXPECT_CALL(*file, flush())
 
2513
        .Times(1)
 
2514
        .WillOnce(Return(true));
 
2515
 
2489
2516
    EXPECT_CALL(*file.data(), remove())
2490
2517
        .Times(1)
2491
2518
        .WillOnce(Return(true));
2601
2628
        .Times(1)
2602
2629
        .WillOnce(Return(true));
2603
2630
 
 
2631
    EXPECT_CALL(*file, flush())
 
2632
        .Times(1)
 
2633
        .WillOnce(Return(true));
 
2634
 
2604
2635
    EXPECT_CALL(*file.data(), remove())
2605
2636
        .Times(1)
2606
2637
        .WillOnce(Return(true));
2707
2738
        .Times(1)
2708
2739
        .WillOnce(Return(true));
2709
2740
 
 
2741
    EXPECT_CALL(*file, flush())
 
2742
        .Times(1)
 
2743
        .WillOnce(Return(true));
 
2744
 
2710
2745
    EXPECT_CALL(*file.data(), remove())
2711
2746
        .Times(1)
2712
2747
        .WillOnce(Return(true));
3203
3238
    EXPECT_CALL(*file, reset())
3204
3239
        .Times(1);
3205
3240
 
 
3241
    EXPECT_CALL(*file, flush())
 
3242
        .Times(1)
 
3243
        .WillOnce(Return(true));
 
3244
 
3206
3245
    EXPECT_CALL(*file, remove())
3207
3246
        .Times(0);
3208
3247
 
3278
3317
    EXPECT_CALL(*reply.data(), setReadBufferSize(_))
3279
3318
        .Times(1);
3280
3319
 
 
3320
    EXPECT_CALL(*reply, attribute(_))
 
3321
        .Times(1)
 
3322
        .WillOnce(Return(QVariant(200)));
 
3323
 
 
3324
    EXPECT_CALL(*reply, hasRawHeader(_))
 
3325
        .Times(2)
 
3326
        .WillOnce(Return(false))
 
3327
        .WillOnce(Return(false));
 
3328
 
3281
3329
    // file system expectations
3282
3330
    EXPECT_CALL(*_fileManager, createFile(_))
3283
3331
        .Times(1)
3290
3338
    EXPECT_CALL(*file.data(), write(_))
3291
3339
        .Times(1)
3292
3340
        .WillOnce(Return(0));
3293
 
 
 
3341
    
3294
3342
    EXPECT_CALL(*file.data(), flush())
3295
3343
        .Times(1)
3296
3344
        .WillOnce(Return(false));
3297
3345
 
 
3346
    EXPECT_CALL(*file.data(), size())
 
3347
        .Times(1)
 
3348
        .WillOnce(Return(0));
 
3349
 
3298
3350
    EXPECT_CALL(*file.data(), error())
3299
3351
        .Times(1)
3300
3352
        .WillOnce(Return(QFile::WriteError));  // any error will do
3307
3359
        _isConfined, _rootPath, _url, _metadata, _headers);
3308
3360
    SignalBarrier spy(download, SIGNAL(error(QString)));
3309
3361
    SignalBarrier startedSpy(download, SIGNAL(started(bool)));
 
3362
    SignalBarrier progressSpy(download, SIGNAL(progress(qulonglong, qulonglong)));
3310
3363
 
3311
3364
    download->start();
3312
3365
    download->startTransfer();
3313
3366
    QVERIFY(startedSpy.ensureSignalEmitted());
3314
3367
 
3315
 
    reply->downloadProgress(0, 13);  // emit progress so that we try to write
 
3368
    reply->downloadProgress(0, 13);
 
3369
    QVERIFY(progressSpy.ensureSignalEmitted());
 
3370
    reply->finished(); // emit finished signal so that we try to write
3316
3371
 
3317
3372
    // assert that the error signal is emitted
3318
3373
    QVERIFY(spy.ensureSignalEmitted());
3367
3422
        .Times(1)
3368
3423
        .WillOnce(Return(0));
3369
3424
 
3370
 
    EXPECT_CALL(*file.data(), flush())
3371
 
        .Times(1)
3372
 
        .WillOnce(Return(false));
3373
 
 
3374
3425
    EXPECT_CALL(*file.data(), error())
3375
3426
        .Times(1)
3376
3427
        .WillOnce(Return(QFile::WriteError));  // any error will do
3377
3428
 
 
3429
    EXPECT_CALL(*file, flush())
 
3430
        .Times(1)
 
3431
        .WillOnce(Return(false));
 
3432
 
3378
3433
    EXPECT_CALL(*file.data(), remove())
3379
3434
        .Times(1)
3380
3435
        .WillOnce(Return(true));
3554
3609
    EXPECT_CALL(*secondFile, remove())
3555
3610
        .Times(0);
3556
3611
 
 
3612
    EXPECT_CALL(*secondFile, flush())
 
3613
        .Times(1)
 
3614
        .WillOnce(Return(true));
 
3615
 
3557
3616
    EXPECT_CALL(*secondFile, close())
3558
3617
        .Times(1);
3559
3618
 
3702
3761
        .Times(1)
3703
3762
        .WillOnce(Return(true));
3704
3763
 
 
3764
    EXPECT_CALL(*file, flush())
 
3765
        .Times(1)
 
3766
        .WillOnce(Return(true));
 
3767
 
3705
3768
    EXPECT_CALL(*file.data(), remove())
3706
3769
        .Times(1)
3707
3770
        .WillOnce(Return(true));