~unity-api-team/indicator-network/connectivity-api-mobile-data-management-tests

« back to all changes in this revision

Viewing changes to tests/integration/test-connectivity-api.cpp

  • Committer: Antti Kaijanmäki
  • Date: 2016-06-09 14:17:22 UTC
  • Revision ID: antti.kaijanmaki@canonical.com-20160609141722-2i1zv5nv868qtg37
make tests pass.

Show diffs side-by-side

added added

removed removed

Lines of Context:
784
784
 
785
785
    // One of the modems was started and we had no settings.
786
786
    // So we start by assuming mobile data was enabled.
 
787
    if (!connectivity->mobileDataEnabled())
 
788
    {
 
789
        WAIT_FOR_SIGNALS(mobileDataEnabledSpy, 1)
 
790
    }
 
791
    mobileDataEnabledSpy.clear();
787
792
    EXPECT_TRUE(connectivity->mobileDataEnabled());
788
793
 
789
794
    if (!connectivity->simForMobileData())
790
795
    {
791
796
        WAIT_FOR_SIGNALS(simForMobileDataSpy, 1)
792
797
    }
 
798
    simForMobileDataSpy.clear();
 
799
    EXPECT_TRUE(connectivity->simForMobileData() != nullptr);
 
800
 
 
801
 
 
802
    QSignalSpy simsModelRowsInsertedSpy(connectivity->sims(), SIGNAL(rowsInserted(const QModelIndex &, int, int)));
 
803
    QSignalSpy modemsModelRowsInsertedSpy(connectivity->modems(), SIGNAL(rowsInserted(const QModelIndex &, int, int)));
 
804
    WAIT_FOR_ROW_COUNT(simsModelRowsInsertedSpy, connectivity->sims(), 2)
 
805
    WAIT_FOR_ROW_COUNT(modemsModelRowsInsertedSpy, connectivity->modems(), 2)
793
806
 
794
807
    auto modems = getSortedModems(*connectivity);
795
808
    auto simForMobileData = connectivity->simForMobileData();
799
812
    ASSERT_TRUE(secondSim);
800
813
    // These should be the exact same object.
801
814
    EXPECT_TRUE(simForMobileData == secondSim);
802
 
    qDebug() << "SIM FOR MOBILE DATA INDEX " << simForMobileData->path().path();
803
 
    qDebug() << "SECOND SIM INDEX " << secondSim->path().path();
804
815
 
805
816
    // Only the second modem should be powered
806
817
    EXPECT_FALSE(getConnectionManagerProperties(modem)["Powered"].toBool());
813
824
 
814
825
    // Disable all mobile data.
815
826
    connectivity->setMobileDataEnabled(false);
816
 
    if (connectivity->mobileDataEnabled())
817
 
    {
818
 
        WAIT_FOR_SIGNALS(mobileDataEnabledSpy, 1)
819
 
    }
 
827
 
820
828
    WAIT_FOR_SIGNALS(connectionManagerPropertyChangedSpy, 1)
821
829
 
822
830
    // Both modems should by un-powered
823
831
    EXPECT_FALSE(getConnectionManagerProperties(modem)["Powered"].toBool());
824
832
    EXPECT_FALSE(getConnectionManagerProperties(modem2)["Powered"].toBool());
825
833
 
826
 
    WAIT_FOR_SIGNALS(mobileDataEnabledSpy, 1);
827
 
    qDebug() << "SPY:" << mobileDataEnabledSpy.first().first().toBool() << mobileDataEnabledSpy.count();
 
834
    if (connectivity->mobileDataEnabled())
 
835
    {
 
836
        WAIT_FOR_SIGNALS(mobileDataEnabledSpy, 1)
 
837
    }
828
838
    EXPECT_FALSE(connectivity->mobileDataEnabled());
829
839
}
830
840