### ----------------------------------------------------
### -- Gnome::Gtk3
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: t/ProgressBar.rakutest
### ----------------------------------------------------
use v6;
use NativeCall;
use Test;

use Gnome::GObject::Type:api<1>;
use Gnome::GObject::Value:api<1>;
use Gnome::Gtk3::ProgressBar:api<1>;

#use Gnome::N::X:api<1>;
#Gnome::N::debug(:on);

#-------------------------------------------------------------------------------
my Gnome::Gtk3::ProgressBar $pb;
#-------------------------------------------------------------------------------
subtest 'ISA test', {
  $pb .= new;
  isa-ok $pb, Gnome::Gtk3::ProgressBar, '.new()';
}

#-------------------------------------------------------------------------------
unless %*ENV<raku_test_all>:exists {
  done-testing;
  exit;
}

#-------------------------------------------------------------------------------
subtest 'Manipulations', {
  $pb.set-text('My pb');
  is $pb.get-text, 'My pb', '.set-text() / .get-text()';

  $pb.set_fraction(5e-1);
  is $pb.get-fraction, 0.5, '.set_fraction() / .get-fraction()';

  $pb.set-pulse-step(1e-1);
  is $pb.get-pulse-step, 0.1, '.set-pulse-step() / .get-pulse-step()';

  $pb.set-inverted(True);
  is $pb.get-inverted, 1, '.set-inverted() / .get-inverted()';

  $pb.set-ellipsize(2);
  is $pb.get-ellipsize, 2, '.set-ellipsize() / .get-ellipsize()';

  $pb.set-show-text(True);
  is $pb.get-show-text, 1, '.set-show-text() / .get-show-text()';
}

#-------------------------------------------------------------------------------
subtest 'Properties ...', {
  my Gnome::GObject::Value $gv .= new(:init(G_TYPE_BOOLEAN));
  $pb.g-object-get-property( 'inverted', $gv);
  is $gv.get-boolean, True, 'property inverted';
  $gv.clear-object;

  $gv .= new(:init(G_TYPE_BOOLEAN));
  $pb.g-object-get-property( 'show-text', $gv);
  is $gv.get-boolean, True, 'property show-text';
  $gv.clear-object;

  $gv .= new(:init(G_TYPE_DOUBLE));
  $pb.g-object-get-property( 'fraction', $gv);
  is-approx $gv.get-double, 0.5, 'property fraction';
  $gv.clear-object;

  $gv .= new(:init(G_TYPE_DOUBLE));
  $pb.g-object-get-property( 'pulse-step', $gv);
  is-approx $gv.get-double, 0.1, 'property pulse-step';
  $gv.clear-object;

#`{{
  $pb.pulse;
  $pb.pulse;
  is $pb.get-fraction, 0.6, '.set_fraction() / .get-fraction()';
  $gv .= new(:init(G_TYPE_DOUBLE));
  $pb.g-object-get-property( 'fraction', $gv);
  is-approx $gv.get-double, 0.6, '.pulse()';
  $gv.clear-object;
}}
}

#`{{
#-------------------------------------------------------------------------------
subtest 'Inherit ...', {
}

#-------------------------------------------------------------------------------
subtest 'Interface ...', {
}

#-------------------------------------------------------------------------------
subtest 'Themes ...', {
}

#-------------------------------------------------------------------------------
subtest 'Signals ...', {
}
}}

#-------------------------------------------------------------------------------
done-testing;


