Skip to content

Commit

Permalink
Adding first test #329
Browse files Browse the repository at this point in the history
  • Loading branch information
stsdc committed Oct 31, 2022
1 parent ce97464 commit 06c458b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ subdir('src')
meson.add_install_script('meson/post_install.py')

subdir('po')
subdir('tests')
3 changes: 3 additions & 0 deletions meson/list-app-src.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

find . -name "*.vala"
3 changes: 3 additions & 0 deletions tests/list-src.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

find . -name "*.vala"
13 changes: 13 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
test_sources = files(run_command('list-src.sh', check: true).stdout().strip().split('\n'))


test(
'monitor-statusbar-test',
executable('monitor-statusbar-test', test_sources, [
meson.source_root() / 'src/Widgets/Statusbar/Statusbar.vala',
meson.source_root() / 'src/Resources/ResourcesSerialized.vala',
meson.source_root() / 'src/Utils.vala'
],
project_config,
dependencies: app_dependencies)
)
9 changes: 9 additions & 0 deletions tests/runner.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
void main (string[] args) {

Test.init(ref args);
Gtk.init(ref args);

test_statusbar ();

Test.run();
}
26 changes: 26 additions & 0 deletions tests/test_statusbar.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Monitor;

private void test_statusbar () {

Test.add_func ("/Monitor/Widgets/Statusbar/Statusbar#Statusbar", () => {

var statusbar = new Monitor.Statusbar ();
ResourcesSerialized sysres = ResourcesSerialized () {
cpu_percentage = 99,
cpu_frequency = 1.44,
cpu_temperature = 34.0,
memory_percentage = 99,
memory_used = 2.0,
memory_total = 4.0,
swap_percentage = 1,
swap_used = 0.1,
swap_total = 1.0,
network_up = 12,
network_down = 23
};

bool update_result = statusbar.update (sysres);

assert (update_result == true);
});
}

0 comments on commit 06c458b

Please sign in to comment.