예제 #1
0
void TestQgsDockWidget::testSignals()
{
  QWidget *w = new QWidget();
  QApplication::setActiveWindow( w ); //required for focus events
  QgsDockWidget *d = new QgsDockWidget( w );

  QSignalSpy spyClosedStateChanged( d, SIGNAL( closedStateChanged( bool ) ) );
  QSignalSpy spyClosed( d, SIGNAL( closed() ) );
  QSignalSpy spyOpenedStateChanged( d, SIGNAL( openedStateChanged( bool ) ) );
  QSignalSpy spyOpened( d, SIGNAL( opened() ) );

  w->show();

  d->show();
  QCOMPARE( spyClosedStateChanged.count(), 1 );
  QCOMPARE( spyClosedStateChanged.last().at( 0 ).toBool(), false );
  QCOMPARE( spyOpenedStateChanged.count(), 1 );
  QCOMPARE( spyOpenedStateChanged.last().at( 0 ).toBool(), true );
  QCOMPARE( spyClosed.count(), 0 );
  QCOMPARE( spyOpened.count(), 1 );

  d->close();
  QCOMPARE( spyClosedStateChanged.count(), 2 );
  QCOMPARE( spyClosedStateChanged.last().at( 0 ).toBool(), true );
  QCOMPARE( spyOpenedStateChanged.count(), 2 );
  QCOMPARE( spyOpenedStateChanged.last().at( 0 ).toBool(), false );
  QCOMPARE( spyClosed.count(), 1 );
  QCOMPARE( spyOpened.count(), 1 );

  delete w;
}
예제 #2
0
void TestQgsDockWidget::testUserVisible()
{
  QgsDockWidget *w = new QgsDockWidget();
  QVERIFY( !w->isUserVisible() );

  w->show();
  QVERIFY( w->isUserVisible() );

  w->hide();
  QVERIFY( !w->isUserVisible() );
  delete w;
}