Ejemplo n.º 1
0
 void testIntialOwnership()
 {
     Legend* l = new Legend( m_chart );
     m_chart->addLegend( l );
     QCOMPARE( m_chart->legend(), l );
     QCOMPARE( l->diagram(), (AbstractDiagram*)0);
     l->setDiagram( m_lines );
     QCOMPARE( dynamic_cast< LineDiagram * >(l->diagram()), m_lines );
 }
Ejemplo n.º 2
0
 void testReplacing()
 {
     Legend* l = new Legend( m_chart );
     QPointer<Legend> oldLegend = m_chart->legend();
     QCOMPARE( dynamic_cast< LineDiagram * >(oldLegend->diagram()), m_lines );
     m_chart->replaceLegend( l, oldLegend );
     QVERIFY( oldLegend.isNull() );
     QCOMPARE( l->diagram(), (AbstractDiagram*)0 );
     l->setDiagram( m_lines );
     QCOMPARE( dynamic_cast< LineDiagram * >(l->diagram()), m_lines );
 }
Ejemplo n.º 3
0
 void testTypeChangeWithLegend()
 {
     //set Cartesian type
     m_widget->addLegend( Position::North );
     QCOMPARE( m_widget->allLegends().size(), 1 );
     m_widget->setType( Widget::Bar, Widget::Stacked );
     Legend *legend = m_widget->legend();
     QVERIFY( legend != 0 );
     QVERIFY( legend->diagram() != 0 );
     QCOMPARE( legend->diagram(), m_widget->diagram() );
     QCOMPARE( m_widget->allLegends().size(), 1 );
     m_widget->setType( Widget::Line );
 }
Ejemplo n.º 4
0
 void testDiagramOwnership()
 {
     Legend* l = new Legend( m_chart );
     QVERIFY( l->diagrams().size() == 0 );
     l->addDiagram( m_lines );
     QVERIFY( l->diagrams().size() == 1 );
     l->addDiagram( m_bars );
     QVERIFY( l->diagrams().size() == 2 );
     QCOMPARE( dynamic_cast< LineDiagram * >(l->diagram()),  m_lines );
     l->removeDiagram( m_lines );
     QVERIFY( l->diagrams().size() == 1 );
     QCOMPARE( dynamic_cast< BarDiagram * >(l->diagram()),  m_bars );
     l->replaceDiagram( m_lines, m_bars );
     QVERIFY( l->diagrams().size() == 1 );
     QCOMPARE( dynamic_cast< LineDiagram * >(l->diagram()),  m_lines );
 }
Ejemplo n.º 5
0
 void testIntialOwnershipFromCtor()
 {
     Legend* l = new Legend( m_lines, m_chart );
     m_chart->replaceLegend( l );
     QCOMPARE( m_chart->legend(), l );
     QCOMPARE( dynamic_cast< LineDiagram * >(l->diagram()), m_lines );
 }