geary/test/client/application/geary-configuration-test.vala
Michael James Gratton 50120c67ff Add simple/demo client unit test using GSettings.
* test/client/application/geary-configuration-test.vala: New unit test
  for Configuration class.

* test/main.vala: Add new unit test to the client suite, ensure the
  memory GSettings backend is used as the default so we get default
  setting values, and never save any changes made.

* test/CMakeLists.txt: Add new unit test source.

* src/client/application/geary-config.vala: Tidy up code a bit to adhere
  to code conventions.
2016-12-26 13:21:58 +10:30

35 lines
1.1 KiB
Vala

/*
* Copyright 2016 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
class ConfigurationTest : Gee.TestCase {
private Configuration test_config = null;
public ConfigurationTest() {
base("ConfigurationTest");
add_test("desktop_environment", desktop_environment);
}
public override void set_up() {
Environment.unset_variable("XDG_CURRENT_DESKTOP");
this.test_config = new Configuration(GearyApplication.APP_ID);
}
public void desktop_environment() {
assert(this.test_config.desktop_environment ==
Configuration.DesktopEnvironment.UNKNOWN);
Environment.set_variable("XDG_CURRENT_DESKTOP", "BLARG", true);
assert(this.test_config.desktop_environment ==
Configuration.DesktopEnvironment.UNKNOWN);
Environment.set_variable("XDG_CURRENT_DESKTOP", "Unity", true);
assert(this.test_config.desktop_environment ==
Configuration.DesktopEnvironment.UNITY);
}
}