I'm on my last two days in brazil, things here are *crazy* right now.
My next patch will be from munich - probably in a mini-hackaton with
robert. :)
From d6ea07936f9261517b9db8a3b46f085f2d6bb332 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@gmail.com>
Date: Fri, 9 Sep 2016 13:32:21 -0300
Subject: [PATCH 2/2] Beginning of the DiveComputer unittests.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@gmail.com>
---
 tests/testpreferences.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp
index 4b320b2..72ea73f 100644
--- a/tests/testpreferences.cpp
+++ b/tests/testpreferences.cpp
@@ -73,6 +73,22 @@ void TestPreferences::testPreferences()
 	TEST(cloud->verificationStatus(), (short)0);
 	cloud->setVerificationStatus(1);
 	TEST(cloud->verificationStatus(), (short)1);
+
+	auto dc = pref->dive_computer_settings;
+	dc->setDevice("TomazComputer");
+	TEST(dc->dc_device(), QStringLiteral("TomazComputer"));
+	dc->setDevice("Deepwater");
+	TEST(dc->dc_device(), QStringLiteral("Deepwater"));
+
+	dc->setDownloadMode(0);
+	TEST(dc->downloadMode(), 0);
+	dc->setDownloadMode(1);
+	TEST(dc->downloadMode(), 1);
+
+	dc->setProduct("Thingy1");
+	TEST(dc->dc_product(), QStringLiteral("Thingy1"));
+	dc->setProduct("Thingy2");
+	TEST(dc->dc_product(), QStringLiteral("Thingy2"));
 }
 
 QTEST_MAIN(TestPreferences)
-- 
2.10.0

From 218a33bc4b507a44385b5fbd6240c6b732590eee Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@gmail.com>
Date: Fri, 9 Sep 2016 11:06:01 -0300
Subject: [PATCH 1/2] Finished unittest for cloud storage.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@gmail.com>
---
 tests/testpreferences.cpp | 71 ++++++++++++++++++++++++++++++++++-------------
 1 file changed, 52 insertions(+), 19 deletions(-)

diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp
index 3148bff..4b320b2 100644
--- a/tests/testpreferences.cpp
+++ b/tests/testpreferences.cpp
@@ -21,25 +21,58 @@ void TestPreferences::testPreferences()
 	pref->animation_settings->setAnimationSpeed(30);
 	TEST(pref->animation_settings->animationSpeed(), 30);
 
-	pref->cloud_storage->setBackgroundSync(true);
-	TEST(pref->cloud_storage->backgroundSync(), true);
-	pref->cloud_storage->setBackgroundSync(false);
-	TEST(pref->cloud_storage->backgroundSync(), false);
-
-	pref->cloud_storage->setBaseUrl("test_one");
-	TEST(pref->cloud_storage->baseUrl(), QStringLiteral("test_one"));
-	pref->cloud_storage->setBaseUrl("test_two");
-	TEST(pref->cloud_storage->baseUrl(), QStringLiteral("test_two"));
-
-	pref->cloud_storage->setEmail("to...@subsurface.com");
-	TEST(pref->cloud_storage->email(), QStringLiteral("to...@subsurface.com"));
-	pref->cloud_storage->setEmail("to...@gmail.com");
-	TEST(pref->cloud_storage->email(), QStringLiteral("to...@gmail.com"));
-
-	pref->cloud_storage->setGitLocalOnly(true);
-	TEST(pref->cloud_storage->gitLocalOnly(), true);
-	pref->cloud_storage->setGitLocalOnly(false);
-	TEST(pref->cloud_storage->gitLocalOnly(), false);
+	auto cloud = pref->cloud_storage;
+	cloud->setBackgroundSync(true);
+	TEST(cloud->backgroundSync(), true);
+	cloud->setBackgroundSync(false);
+	TEST(cloud->backgroundSync(), false);
+
+	cloud->setBaseUrl("test_one");
+	TEST(cloud->baseUrl(), QStringLiteral("test_one"));
+	cloud->setBaseUrl("test_two");
+	TEST(cloud->baseUrl(), QStringLiteral("test_two"));
+
+	cloud->setEmail("to...@subsurface.com");
+	TEST(cloud->email(), QStringLiteral("to...@subsurface.com"));
+	cloud->setEmail("to...@gmail.com");
+	TEST(cloud->email(), QStringLiteral("to...@gmail.com"));
+
+	cloud->setGitLocalOnly(true);
+	TEST(cloud->gitLocalOnly(), true);
+	cloud->setGitLocalOnly(false);
+	TEST(cloud->gitLocalOnly(), false);
+
+	// Why there's new password and password on the prefs?
+	cloud->setNewPassword("ABCD");
+	TEST(cloud->newPassword(), QStringLiteral("ABCD"));
+	cloud->setNewPassword("ABCDE");
+	TEST(cloud->newPassword(), QStringLiteral("ABCDE"));
+
+	cloud->setPassword("ABCDE");
+	TEST(cloud->password(), QStringLiteral("ABCDE"));
+	cloud->setPassword("ABCABC");
+	TEST(cloud->password(), QStringLiteral("ABCABC"));
+
+	cloud->setSavePasswordLocal(true);
+	TEST(cloud->savePasswordLocal(), true);
+	cloud->setSavePasswordLocal(false);
+	TEST(cloud->savePasswordLocal(), false);
+
+	// Why this is short and not bool?
+	cloud->setSaveUserIdLocal(1);
+	TEST(cloud->saveUserIdLocal(), (short)1);
+	cloud->setSavePasswordLocal(0);
+	TEST(cloud->saveUserIdLocal(), (short)0);
+
+	cloud->setUserId("Tomaz");
+	TEST(cloud->userId(), QStringLiteral("Tomaz"));
+	cloud->setUserId("Zamot");
+	TEST(cloud->userId(), QStringLiteral("Zamot"));
+
+	cloud->setVerificationStatus(0);
+	TEST(cloud->verificationStatus(), (short)0);
+	cloud->setVerificationStatus(1);
+	TEST(cloud->verificationStatus(), (short)1);
 }
 
 QTEST_MAIN(TestPreferences)
-- 
2.10.0

_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to