~alecu/unity-scope-click/uninstallable-scopes

« back to all changes in this revision

Viewing changes to libclickscope/tests/test_interface.cpp

  • Committer: Alejandro J. Cura
  • Date: 2014-06-12 21:05:25 UTC
  • Revision ID: alecu@canonical.com-20140612210525-g9jyrd3z66468gfv
A few refactorings to ease the following branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
 
119
119
class ClickInterfaceTest : public ::testing::Test {
120
120
public:
121
 
    MOCK_METHOD2(manifest_callback, void(Manifest, ManifestError));
122
 
    MOCK_METHOD2(manifests_callback, void(ManifestList, ManifestError));
 
121
    MOCK_METHOD2(manifest_callback, void(Manifest, InterfaceError));
 
122
    MOCK_METHOD2(manifests_callback, void(ManifestList, InterfaceError));
123
123
};
124
124
 
125
125
}
354
354
    std::string command = "click info " + FAKE_PACKAGENAME;
355
355
    EXPECT_CALL(iface, run_process(command, _)).
356
356
        Times(1);
357
 
    iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest, ManifestError){});
 
357
    iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest, InterfaceError){});
358
358
}
359
359
 
360
360
TEST_F(ClickInterfaceTest, testGetManifestForAppParseError)
367
367
                                               const std::string&)> callback){
368
368
                            callback(0, "INVALID JSON", "");
369
369
                        }));
370
 
    EXPECT_CALL(*this, manifest_callback(_, ManifestError::ParseError));
 
370
    EXPECT_CALL(*this, manifest_callback(_, InterfaceError::ParseError));
371
371
    iface.get_manifest_for_app(FAKE_PACKAGENAME, [this](Manifest manifest,
372
 
                                                        ManifestError error){
 
372
                                                        InterfaceError error){
373
373
                                   manifest_callback(manifest, error);
374
374
                               });
375
375
}
384
384
                                               const std::string&)> callback){
385
385
                            callback(-1, "", "CRITICAL: FAIL");
386
386
                        }));
387
 
    EXPECT_CALL(*this, manifest_callback(_, ManifestError::CallError));
 
387
    EXPECT_CALL(*this, manifest_callback(_, InterfaceError::CallError));
388
388
    iface.get_manifest_for_app(FAKE_PACKAGENAME, [this](Manifest manifest,
389
 
                                                        ManifestError error){
 
389
                                                        InterfaceError error){
390
390
                                   manifest_callback(manifest, error);
391
391
                               });
392
392
}
402
402
                            callback(0, FAKE_JSON_MANIFEST_REMOVABLE, "");
403
403
                        }));
404
404
    iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest manifest,
405
 
                                                    ManifestError error){
406
 
                                   ASSERT_TRUE(error == ManifestError::NoError);
 
405
                                                    InterfaceError error){
 
406
                                   ASSERT_TRUE(error == InterfaceError::NoError);
407
407
                                   ASSERT_TRUE(manifest.removable);
408
408
                               });
409
409
}
419
419
                            callback(0, FAKE_JSON_MANIFEST_NONREMOVABLE, "");
420
420
                        }));
421
421
    iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest manifest,
422
 
                                                    ManifestError error){
423
 
                                   ASSERT_TRUE(error == ManifestError::NoError);
 
422
                                                    InterfaceError error){
 
423
                                   ASSERT_TRUE(error == InterfaceError::NoError);
424
424
                                   ASSERT_FALSE(manifest.removable);
425
425
                               });
426
426
}
431
431
    std::string command = "click list --manifest";
432
432
    EXPECT_CALL(iface, run_process(command, _)).
433
433
        Times(1);
434
 
    iface.get_manifests([](ManifestList, ManifestError){});
 
434
    iface.get_manifests([](ManifestList, InterfaceError){});
435
435
}
436
436
 
437
437
TEST_F(ClickInterfaceTest, testGetManifestsParseError)
444
444
                                               const std::string&)> callback){
445
445
                            callback(0, "INVALID JSON", "");
446
446
                        }));
447
 
    EXPECT_CALL(*this, manifests_callback(_, ManifestError::ParseError));
448
 
    iface.get_manifests([this](ManifestList manifests, ManifestError error){
 
447
    EXPECT_CALL(*this, manifests_callback(_, InterfaceError::ParseError));
 
448
    iface.get_manifests([this](ManifestList manifests, InterfaceError error){
449
449
            manifests_callback(manifests, error);
450
450
        });
451
451
}
460
460
                                               const std::string&)> callback){
461
461
                            callback(-1, "", "CRITICAL: FAIL");
462
462
                        }));
463
 
    EXPECT_CALL(*this, manifests_callback(_, ManifestError::CallError));
464
 
    iface.get_manifests([this](ManifestList manifests, ManifestError error){
 
463
    EXPECT_CALL(*this, manifests_callback(_, InterfaceError::CallError));
 
464
    iface.get_manifests([this](ManifestList manifests, InterfaceError error){
465
465
            manifests_callback(manifests, error);
466
466
        });
467
467
}
480
480
                                               const std::string&)> callback){
481
481
                            callback(0, expected_str, "");
482
482
                        }));
483
 
    iface.get_manifests([expected](ManifestList manifests, ManifestError error){
484
 
            ASSERT_TRUE(error == ManifestError::NoError);
 
483
    iface.get_manifests([expected](ManifestList manifests, InterfaceError error){
 
484
            ASSERT_TRUE(error == InterfaceError::NoError);
485
485
            ASSERT_TRUE(manifests.size() == expected.size());
486
486
        });
487
487
}