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

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

use Gnome::Gtk3::Frame:api<1>;
use Gnome::Gtk3::Enums:api<1>;
use Gnome::Gtk3::Label:api<1>;

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

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

  $f .= new(:label('frame label'));
  isa-ok $f, Gnome::Gtk3::Frame, '.new(:label)';
}

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

#-------------------------------------------------------------------------------
subtest 'Inherit Gnome::Gtk3::Frame', {
  class MyClass is Gnome::Gtk3::Frame {
    method new ( |c ) {
      self.bless( :GtkFrame, |c);
    }

    submethod BUILD ( *%options ) {

    }
  }

  my MyClass $mgc .= new;
  isa-ok $mgc, Gnome::Gtk3::Frame, 'MyClass.new()';
}

#-------------------------------------------------------------------------------
subtest 'Manipulations', {
  $f.set-label('blah');
  is $f.get-label, 'blah', '.set-label() / .get-label()';

  my Gnome::Gtk3::Label $l .= new(:native-object($f.get-label-widget));
  is $l.get-text, 'blah', '.get-label-widget()';

  # create a label without parent, previous one has frame as a parent!
  $l .= new(:text('new label'));
  $f.set-label-widget($l);
  is $f.get-label, 'new label', '.set-label-widget()';

  $f.set-label-align( 0.8e0, 0.03e0);
  my Num ( $xa, $ya) = $f.get-label-align;
  is-approx $xa, 0.8e0, '.get-label-align() xalign ok';
  is-approx $ya, 0.03e0, '.get-label-align() yalign ok';

  $f.set-shadow-type(GTK_SHADOW_IN);
  is GtkShadowType($f.get-shadow-type), GTK_SHADOW_IN,
    '.set-shadow-type() / .get-shadow-type()';
}

#-------------------------------------------------------------------------------
subtest 'Properties …', {
#  my Gnome::Gtk3::Frame $f .= new;
  my @r = $f.get-properties(
    'label', Str, 'label-xalign', gfloat, 'label-yalign', gfloat,
    'shadow-type', GEnum, 'label-widget', gpointer
  );

  is @r[0], 'new label', 'label';
  is-approx @r[1], 0.8e0, 'property label-xalign';
  is-approx @r[2], 0.03e0, 'property label-yalign';
  is @r[3], GTK_SHADOW_IN.value, 'property shadow-type';

  my Gnome::Gtk3::Label() $l = @r[4];
  is $l.get-text, 'new label', 'property label-widget';
}

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

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

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

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

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


