phoneuis/bubblemanager2/tsrc/unit/loctest/loctest.cpp
changeset 64 6aaf0276100e
parent 45 6b911d05207e
child 74 d1c62c765e48
equal deleted inserted replaced
56:5bcb308bd24d 64:6aaf0276100e
    21 #include <hbapplication.h>
    21 #include <hbapplication.h>
    22 #include <hbmainwindow.h>
    22 #include <hbmainwindow.h>
    23 #include <hbaction.h>
    23 #include <hbaction.h>
    24 #include <hbtoolbar.h>
    24 #include <hbtoolbar.h>
    25 #include <hbview.h>
    25 #include <hbview.h>
    26 #include <private/hbtextmeasurementutility_p.h> // hb "configure --developer" required
    26 #include <restricted/hbtextmeasurementutility_r.h> // hb "configure --developer" required
       
    27 #include <restricted/hbfeaturemanager_r.h>
    27 #include <hbdeviceprofile.h>
    28 #include <hbdeviceprofile.h>
    28 
    29 
    29 #include "bubbletest.h"
    30 #include "bubbletest.h"
    30 #include "bubblemanager2.h"
    31 #include "bubblemanager2.h"
    31 
    32 
    38 private slots:
    39 private slots:
    39     void initTestCase();
    40     void initTestCase();
    40     void cleanupTestCase();
    41     void cleanupTestCase();
    41 
    42 
    42     void testPortraitStrings();
    43     void testPortraitStrings();
    43 
       
    44     void changeOrientation();
    44     void changeOrientation();
    45 
       
    46     void testLandscapeStrings();
    45     void testLandscapeStrings();
    47 
    46 
    48 private:
    47 private:
    49     void testLabel(int bubbleId, const char *id);
    48     void testLabel(int bubbleId, const char *id);
    50     void testCli(int bubbleId, const char *id);
    49     void testCli(int bubbleId, const char *id);
    71     toolBar->addAction( toolbarAction );
    70     toolBar->addAction( toolbarAction );
    72     toolBar->addAction( toolbarAction );
    71     toolBar->addAction( toolbarAction );
    73     mainWindow->currentView()->setToolBar(toolBar);
    72     mainWindow->currentView()->setToolBar(toolBar);
    74 
    73 
    75     mainWindow->show();
    74     mainWindow->show();
       
    75 
       
    76     HbFeatureManager::instance()->setFeatureStatus(
       
    77         HbFeatureManager::TextMeasurement, true);
       
    78 
    76     QTest::qWait( 3000 );
    79     QTest::qWait( 3000 );
    77 }
    80 }
    78 
    81 
    79 void LocTest::cleanupTestCase()
    82 void LocTest::cleanupTestCase()
    80 {
    83 {
    84 
    87 
    85 void LocTest::testPortraitStrings()
    88 void LocTest::testPortraitStrings()
    86 {
    89 {
    87     view->setTitle( "Measuring portrait" );
    90     view->setTitle( "Measuring portrait" );
    88 
    91 
    89     // In portrait all text fields have same width, only font
    92     // texts fields are measured according to most narrow situation
    90     // is different between label and cli field.
       
    91 
    93 
    92     // create test bubble
    94     // create test bubble
    93     bubbleManager->startChanges();
    95     bubbleManager->startChanges();
    94     int bubbleId = bubbleManager->createCallHeader();
    96     int bubbleId = bubbleManager->createCallHeader();
    95     bubbleManager->setState( bubbleId, BubbleManager::Incoming );
    97     bubbleManager->setState( bubbleId, BubbleManager::Incoming );
    98     bubbleManager->addAction( bubbleId, &action1 );
   100     bubbleManager->addAction( bubbleId, &action1 );
    99     HbAction action2("Reject", this);
   101     HbAction action2("Reject", this);
   100     action2.setSoftKeyRole(QAction::NegativeSoftKey);
   102     action2.setSoftKeyRole(QAction::NegativeSoftKey);
   101     bubbleManager->addAction( bubbleId, &action2 );
   103     bubbleManager->addAction( bubbleId, &action2 );
   102     bubbleManager->setCallObjectFromTheme(bubbleId);
   104     bubbleManager->setCallObjectFromTheme(bubbleId);
       
   105     bubbleManager->setCallFlag(bubbleId,BubbleManagerIF::NoCiphering,true);
   103     bubbleManager->endChanges();
   106     bubbleManager->endChanges();
   104 
   107 
   105     QTest::qWait( WAIT_TIME );
   108     QTest::qWait( WAIT_TIME );
   106 
   109 
   107     // measure label texts
   110     // measure label texts
       
   111 
       
   112     // First line texts with ciphering indicator
       
   113     bubbleManager->startChanges();
       
   114     bubbleManager->setState( bubbleId, BubbleManager::Outgoing );
       
   115     bubbleManager->endChanges();
       
   116 
   108     testLabel(bubbleId,"txt_phone_other_calling");
   117     testLabel(bubbleId,"txt_phone_other_calling");
   109 
   118 
       
   119     testLabel(bubbleId,"txt_phone_other_attempting");
       
   120 
       
   121     // Second line texts, no indicators -> full width
       
   122     bubbleManager->startChanges();
       
   123     bubbleManager->setState( bubbleId, BubbleManager::Incoming );
       
   124     bubbleManager->endChanges();
       
   125 
   110     testLabel(bubbleId,"txt_phone_other_incoming_call");
   126     testLabel(bubbleId,"txt_phone_other_incoming_call");
   111 
   127 
   112     testLabel(bubbleId,"txt_phone_other_waiting");
   128     testLabel(bubbleId,"txt_phone_other_waiting");
   113 
   129 
   114     testLabel(bubbleId,"txt_phone_other_on_hold");
   130     testLabel(bubbleId,"txt_phone_other_on_hold");
   115 
   131 
   116     testLabel(bubbleId,"txt_phone_other_disconnected");
   132     testLabel(bubbleId,"txt_phone_other_disconnected");
   117 
   133 
   118     testLabel(bubbleId,"txt_phone_other_attempting");
   134     testLabel(bubbleId,"txt_phone_other_incoming_video_call");
   119 
   135 
   120     // measure cli texts
   136     testLabel(bubbleId,"txt_phone_other_incoming_l1_call");
       
   137 
       
   138     // First line CLI texts with ciphering indicator
   121     testCli(bubbleId,"txt_phone_other_conference_call");
   139     testCli(bubbleId,"txt_phone_other_conference_call");
   122 
   140 
       
   141     testCli(bubbleId,"txt_phone_other_remote_sim");
       
   142 
       
   143     testCli(bubbleId,"txt_phone_other_emergency_call");
       
   144 
       
   145     // First line CLI texts with ciphering and divert indicators
       
   146     bubbleManager->startChanges();
       
   147     bubbleManager->setCallFlag( bubbleId, BubbleManager::Diverted, true );
       
   148     bubbleManager->endChanges();
       
   149 
   123     testCli(bubbleId,"txt_phone_other_unknown_number");
   150     testCli(bubbleId,"txt_phone_other_unknown_number");
   124 
   151 
   125     testCli(bubbleId,"txt_phone_other_remote_sim");
       
   126 
       
   127     testCli(bubbleId,"txt_phone_other_private_number");
   152     testCli(bubbleId,"txt_phone_other_private_number");
   128 
   153 
   129     testCli(bubbleId,"txt_phone_other_emergency_call");
   154     testCli(bubbleId,"txt_phone_other_payphone");
       
   155 
       
   156     bubbleManager->startChanges();
       
   157     bubbleManager->setCallFlag( bubbleId, BubbleManager::Diverted, false );
       
   158     bubbleManager->endChanges();
   130 
   159 
   131     // write results
   160     // write results
   132     QTest::qWait( WAIT_TIME );
   161     QTest::qWait( WAIT_TIME );
   133     HbDeviceProfile profile = HbDeviceProfile::profile(mainWindow);
   162     HbDeviceProfile profile = HbDeviceProfile::profile(mainWindow);
   134     QFileInfo info(QCoreApplication::applicationFilePath());
   163     QFileInfo info(QCoreApplication::applicationFilePath());
   144 }
   173 }
   145 
   174 
   146 void LocTest::changeOrientation()
   175 void LocTest::changeOrientation()
   147 {
   176 {
   148     view->setTitle( "Changing orientation" );
   177     view->setTitle( "Changing orientation" );
       
   178     mainWindow->resize(640,360);
   149     mainWindow->setOrientation(Qt::Horizontal);
   179     mainWindow->setOrientation(Qt::Horizontal);
   150     mainWindow->resize(640,360);
       
   151     QTest::qWait(3000);
   180     QTest::qWait(3000);
   152 }
   181 }
   153 
   182 
   154 void LocTest::testLandscapeStrings()
   183 void LocTest::testLandscapeStrings()
   155 {
   184 {
   156     view->setTitle( "Measuring landscape" );
   185     view->setTitle( "Measuring landscape" );
   157 
   186 
   158     // In landscape text field width depends on call situation,
   187     // texts fields are measured according to most narrow situation
   159     // measure according to most narrow case.
       
   160 
   188 
   161     // create test bubble
   189     // create test bubble
   162     bubbleManager->startChanges();
   190     bubbleManager->startChanges();
   163     int bubbleId = bubbleManager->createCallHeader();
   191     int bubbleId = bubbleManager->createCallHeader();
   164     bubbleManager->setState( bubbleId, BubbleManager::OnHold );
   192     bubbleManager->setState( bubbleId, BubbleManager::Incoming );
   165     HbAction action1("End call", this);
   193     HbAction action1("End call", this);
   166     action1.setSoftKeyRole(QAction::PositiveSoftKey);
   194     action1.setSoftKeyRole(QAction::PositiveSoftKey);
   167     bubbleManager->addAction( bubbleId, &action1 );
   195     bubbleManager->addAction( bubbleId, &action1 );
   168     bubbleManager->setCallObjectFromTheme(bubbleId);
   196     bubbleManager->setCallObjectFromTheme(bubbleId);
   169     bubbleManager->endChanges();
   197     bubbleManager->setCallFlag( bubbleId, BubbleManager::NoCiphering, true );
   170 
   198     bubbleManager->endChanges();
   171 
   199 
   172     // only in single call texts
   200     // Single call "only" texts
       
   201 
       
   202     // Second line texts, no indicators -> full width
   173     testLabel(bubbleId,"txt_phone_other_incoming_call");
   203     testLabel(bubbleId,"txt_phone_other_incoming_call");
   174 
   204 
       
   205     testLabel(bubbleId,"txt_phone_other_incoming_video_call");
       
   206 
       
   207     testLabel(bubbleId,"txt_phone_other_incoming_l1_call");
       
   208 
       
   209     bubbleManager->startChanges();
       
   210     bubbleManager->setState( bubbleId, BubbleManager::Outgoing );
       
   211     bubbleManager->endChanges();
       
   212 
       
   213     // First line texts, with ciphering indicator
   175     testLabel(bubbleId,"txt_phone_other_attempting");
   214     testLabel(bubbleId,"txt_phone_other_attempting");
   176 
   215 
       
   216     testLabel(bubbleId,"txt_phone_other_calling");
       
   217 
       
   218     bubbleManager->startChanges();
       
   219     bubbleManager->setState( bubbleId, BubbleManager::Active );
       
   220     bubbleManager->endChanges();
       
   221 
   177     testCli(bubbleId,"txt_phone_other_emergency_call");
   222     testCli(bubbleId,"txt_phone_other_emergency_call");
   178 
   223 
   179     // multicall
   224     // Add another call
   180     bubbleManager->startChanges();
   225     bubbleManager->startChanges();
   181     int bubbleId2 = bubbleManager->createCallHeader();
   226     int bubbleId2 = bubbleManager->createCallHeader();
   182     bubbleManager->setState( bubbleId2, BubbleManager::OnHold );
   227     bubbleManager->setState( bubbleId, BubbleManager::OnHold );
   183     int bubbleId3 = bubbleManager->createCallHeader();
   228     bubbleManager->setState( bubbleId2, BubbleManager::Active );
   184     bubbleManager->setState( bubbleId3, BubbleManager::Waiting );
   229     bubbleManager->setCallObjectFromTheme(bubbleId2);
   185     HbAction action2("Replace", this);
   230     bubbleManager->endChanges();
   186     action2.setSoftKeyRole(QAction::PositiveSoftKey);
   231 
   187     bubbleManager->addAction( bubbleId3, &action1 );
   232     testLabel(bubbleId,"txt_phone_other_on_hold");
   188     bubbleManager->setCallObjectFromTheme(bubbleId3);
   233 
   189     bubbleManager->endChanges();
   234     testLabel(bubbleId,"txt_phone_other_disconnected");
   190 
   235 
   191     // measure label texts
   236     testCli(bubbleId,"txt_phone_other_conference_call");
   192     testLabel(bubbleId2,"txt_phone_other_calling");
   237 
   193 
   238     testCli(bubbleId,"txt_phone_other_remote_sim");
   194     testLabel(bubbleId2,"txt_phone_other_waiting");
   239 
   195 
   240     // Add ciphering indicator
   196     testLabel(bubbleId2,"txt_phone_other_on_hold");
   241     bubbleManager->startChanges();
   197 
   242     bubbleManager->setState( bubbleId, BubbleManager::Waiting );
   198     testLabel(bubbleId2,"txt_phone_other_disconnected");
   243     bubbleManager->setCallFlag( bubbleId, BubbleManager::Diverted, true );
   199 
   244     bubbleManager->endChanges();
   200     // measure cli texts
   245 
   201     testCli(bubbleId2,"txt_phone_other_conference_call");
   246     testCli(bubbleId,"txt_phone_other_unknown_number");
   202 
   247 
   203     testCli(bubbleId3,"txt_phone_other_unknown_number");
   248     testCli(bubbleId,"txt_phone_other_private_number");
   204 
   249 
   205     testCli(bubbleId3,"txt_phone_other_remote_sim");
   250     testCli(bubbleId,"txt_phone_other_payphone");
   206 
   251 
   207     testCli(bubbleId3,"txt_phone_other_private_number");
   252     testLabel(bubbleId,"txt_phone_other_waiting");
   208 
   253 
   209     // write results
   254     // write results
   210     QTest::qWait( WAIT_TIME );
   255     QTest::qWait( WAIT_TIME );
   211     HbDeviceProfile profile = HbDeviceProfile::profile(mainWindow);
   256     HbDeviceProfile profile = HbDeviceProfile::profile(mainWindow);
   212     QFileInfo info(QCoreApplication::applicationFilePath());
   257     QFileInfo info(QCoreApplication::applicationFilePath());
   216 
   261 
   217     QTest::qWait( WAIT_TIME );
   262     QTest::qWait( WAIT_TIME );
   218     bubbleManager->startChanges();
   263     bubbleManager->startChanges();
   219     bubbleManager->removeCallHeader( bubbleId );
   264     bubbleManager->removeCallHeader( bubbleId );
   220     bubbleManager->removeCallHeader( bubbleId2 );
   265     bubbleManager->removeCallHeader( bubbleId2 );
   221     bubbleManager->removeCallHeader( bubbleId3 );
       
   222     bubbleManager->endChanges();
   266     bubbleManager->endChanges();
   223     QTest::qWait( WAIT_TIME );
   267     QTest::qWait( WAIT_TIME );
   224 }
   268 }
   225 
   269 
   226 void LocTest::testLabel(int bubbleId, const char *id)
   270 void LocTest::testLabel(int bubbleId, const char *id)