tests: move CloudStorage test from testpreferences

Remove CloudStorage test in testpreferences
add the same CloudStorage tests to testqPrefCloudStorage

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-07-15 13:53:03 +02:00 committed by Dirk Hohndel
parent cabdf71bf7
commit be8e93d28a
3 changed files with 58 additions and 48 deletions

View file

@ -24,54 +24,6 @@ void TestPreferences::testPreferences()
auto pref = SettingsObjectWrapper::instance();
pref->load();
auto cloud = pref->cloud_storage;
cloud->set_cloud_base_url("test_one");
TEST(cloud->cloud_base_url(), QStringLiteral("test_one"));
cloud->set_cloud_base_url("test_two");
TEST(cloud->cloud_base_url(), QStringLiteral("test_two"));
cloud->set_cloud_storage_email("tomaz@subsurface.com");
TEST(cloud->cloud_storage_email(), QStringLiteral("tomaz@subsurface.com"));
cloud->set_cloud_storage_email("tomaz@gmail.com");
TEST(cloud->cloud_storage_email(), QStringLiteral("tomaz@gmail.com"));
cloud->set_git_local_only(true);
TEST(cloud->git_local_only(), true);
cloud->set_git_local_only(false);
TEST(cloud->git_local_only(), false);
// Why there's new password and password on the prefs?
cloud->set_cloud_storage_newpassword("ABCD");
TEST(cloud->cloud_storage_newpassword(), QStringLiteral("ABCD"));
cloud->set_cloud_storage_newpassword("ABCDE");
TEST(cloud->cloud_storage_newpassword(), QStringLiteral("ABCDE"));
cloud->set_cloud_storage_password("ABCDE");
TEST(cloud->cloud_storage_password(), QStringLiteral("ABCDE"));
cloud->set_cloud_storage_password("ABCABC");
TEST(cloud->cloud_storage_password(), QStringLiteral("ABCABC"));
cloud->set_save_password_local(true);
TEST(cloud->save_password_local(), true);
cloud->set_save_password_local(false);
TEST(cloud->save_password_local(), false);
cloud->set_save_userid_local(1);
TEST(cloud->save_userid_local(), true);
cloud->set_save_userid_local(0);
TEST(cloud->save_userid_local(), false);
cloud->set_userid("Tomaz");
TEST(cloud->userid(), QStringLiteral("Tomaz"));
cloud->set_userid("Zamot");
TEST(cloud->userid(), QStringLiteral("Zamot"));
cloud->set_cloud_verification_status(0);
TEST(cloud->cloud_verification_status(), (short)0);
cloud->set_cloud_verification_status(1);
TEST(cloud->cloud_verification_status(), (short)1);
auto tecDetails = pref->techDetails;
tecDetails->setModpO2(0.2);
TEST(tecDetails->modpO2(), 0.2);

View file

@ -206,4 +206,61 @@ void TestQPrefCloudStorage::test_multiple()
QCOMPARE(tst->cloud_timeout(), tst_direct->cloud_timeout());
}
#define TEST(METHOD, VALUE) \
QCOMPARE(METHOD, VALUE); \
cloud->sync(); \
cloud->load(); \
QCOMPARE(METHOD, VALUE);
void TestQPrefCloudStorage::test_oldPreferences()
{
auto cloud = qPrefCloudStorage::instance();
cloud->set_cloud_base_url("test_one");
TEST(cloud->cloud_base_url(), QStringLiteral("test_one"));
cloud->set_cloud_base_url("test_two");
TEST(cloud->cloud_base_url(), QStringLiteral("test_two"));
cloud->set_cloud_storage_email("tomaz@subsurface.com");
TEST(cloud->cloud_storage_email(), QStringLiteral("tomaz@subsurface.com"));
cloud->set_cloud_storage_email("tomaz@gmail.com");
TEST(cloud->cloud_storage_email(), QStringLiteral("tomaz@gmail.com"));
cloud->set_git_local_only(true);
TEST(cloud->git_local_only(), true);
cloud->set_git_local_only(false);
TEST(cloud->git_local_only(), false);
// Why there's new password and password on the prefs?
cloud->set_cloud_storage_newpassword("ABCD");
TEST(cloud->cloud_storage_newpassword(), QStringLiteral("ABCD"));
cloud->set_cloud_storage_newpassword("ABCDE");
TEST(cloud->cloud_storage_newpassword(), QStringLiteral("ABCDE"));
cloud->set_cloud_storage_password("ABCDE");
TEST(cloud->cloud_storage_password(), QStringLiteral("ABCDE"));
cloud->set_cloud_storage_password("ABCABC");
TEST(cloud->cloud_storage_password(), QStringLiteral("ABCABC"));
cloud->set_save_password_local(true);
TEST(cloud->save_password_local(), true);
cloud->set_save_password_local(false);
TEST(cloud->save_password_local(), false);
cloud->set_save_userid_local(1);
TEST(cloud->save_userid_local(), true);
cloud->set_save_userid_local(0);
TEST(cloud->save_userid_local(), false);
cloud->set_userid("Tomaz");
TEST(cloud->userid(), QStringLiteral("Tomaz"));
cloud->set_userid("Zamot");
TEST(cloud->userid(), QStringLiteral("Zamot"));
cloud->set_cloud_verification_status(0);
TEST(cloud->cloud_verification_status(), 0);
cloud->set_cloud_verification_status(1);
TEST(cloud->cloud_verification_status(), 1);
}
QTEST_MAIN(TestQPrefCloudStorage)

View file

@ -15,6 +15,7 @@ private slots:
void test_set_load_struct();
void test_struct_disk();
void test_multiple();
void test_oldPreferences();
};
#endif // TESTQPREFCLOUDSTORAGE_H