Basic Functional Testing of SigmaTestApp



Test Content

Testing the basic functions of SigmaTestApp on different models of devices:

1) Test if the SETTINGS button takes effect.

2) Test if the text entered in the TIMEOUT input box is correct.

3) Test if the page sliding is correct.

4) Test if the input box is correct.

5) Test if the sliding bar is correct.

6) Tests if the multi-select box is correct.



View Video




Test Environment

Test Equipment

In order to test coverage on different device models, Huawei Hongmeng (Hongmeng 2.0), Samsung S10 (Android 13), Redmi 9A (Android 10), and OnePlus A6000 (Android 11) were selected for testing.



Test App

The test uses the SigmaTestApp, which you can get yourself and is located in the APK directory of the Total Control installation.




Script

Scripting Languages

This script uses JavaScript.

Total Control comes with a JavaScript script execution compiler and integrates with the Ringo library. You can use JavaScript to write your automation scripts. If you are familiar with other languages, we provide a REST API interface that you can use to call the REST API to operate the device and perform automation tests.



Script Editing Software

You can use any text editing software, and after editing, store the script file in the Total Control default script directory, which can be changed.




Code

/**
*Set common function: Start the app for testing
*/
function restart_test_app() {
  devices.send(tcConst.KEY_HOME);
  delay(3000)
  var step1 = devices.sendAai({ action: "restartApp(com.sigma_rt.sigmatestapp)" }); //Launch the corresponding app that needs to be tested
  if (step1.success() != true) {
    print("Failed to start app execution: Failed to start app Step 1 " + step1);
    return false;
  }
  delay(3000)
  var step2 = devices.sendAai({ action: "waitQuery('T:ci:SETTINGS',5000)" });//Wait for a special button to appear that identifies the successful start of the app, where ci indicates case insensitivity
  if (step2.success() != true) {
    print("Failed to start app execution: Failed to start app Step 2 " + step2);
    return false;
  }
  return true;
}

/**
* TestCase 1: Test whether clicking the SETTings button takes effect
*      Initial condition: Start the testing app
*      Test steps: 1) Click the corresponding button on the page
*                  2) A new page should pop up (check whether the page pops up by verifying key nodes) 
*/
function case1_test_click() {
  if (restart_test_app() == false) {
    print("case1_test_click Execution failure: Failed to start app");
  }
  var step1 = devices.clickSync("SETTINGS"); //Click on the SETTINGS button to test
  if (step1.success() != true) {
    print("case1_test_click Execution failure: clicking on the SETTINGS button failed");
    return false;
  }
  var step2 = devices.sendAai({ action: "waitQuery('T:GO',25000)" });//A GO text will appear on the new page for inspection
  if (step2.success() != true) {
    print("case1_test_click Execution failure: After clicking the SETTINGS button, no GO page appears ");
    return false;
  }
  print("case1_test_click Execution successful");
}

/**
* TestCase 2: Test TIMEOUT input box input
*      Initial condition: Start the testing app
*      Test steps: 1) Enter information in the TIMEOUT input box
*                  2) Check if all phones input normally and can be displayed
*                  3) Test the timeout function and obtain T: FINISH before timeout!! Should have failed
*    			   4) Test the timeout function and obtain T: FINISH after timeout!! Should be successful
*/
function case2_test_timeout_input() {
  if (restart_test_app() == false) {
    print("case2_test_timeout_input Failed to start app");
  }
  var step1 = devices.inputTextSync(0, "30000"); //Enter in the first input box
  if (step1.success() != true) {
    print("case2_test_timeout_input Execution failure: input text error" + step2);
    return;
  }
  var step2 = devices.sendAai({ query: "T:ci:Timeout||OX:1", action: "getText" });//Obtain the text in the input box for verification
  if (step2.success() != true) {
    print("case2_test_timeout_input Execution failed: the text did not appear in the input box after input ");
    return false;
  }
  //Test whether the input time really takes effect
  devices.sendAai({ query: "T:TIMEOUT", postAction: "click" })
  //When 25000 milliseconds, FINISH should not be displayed!!
  delay(25000)
  var step3 = devices.sendAai({ query: "T:FINISH!!" });//Normally, you need to wait for a timeout time to obtain it. If you try to obtain it earlier, it should fail
  if (step3.success() == true) {
    print("case2_test_timeout_input Execution failure: The TIMEOUT input did not really take effect ");
    return false;
  }
  delay(5000) //Continuing to wait for 5000 milliseconds
  var step4 = devices.sendAai({ query: "T:FINISH!!" });//Normally, you need to wait for a timeout time to obtain it. Now, after the timeout time, it should be successful to obtain it again
  if (step4.success() != true) {
    print("case2_test_timeout_input Execution failure: No waiting text appears after TIMEOUT time");
    return false;
  }
  print("case2_test_timeout_input Execution successful");
}

/**
* TestCase 3: Sliding Search of Test List
*      Initial condition: Start the testing app
*      Test steps: 1) Scroll to find the specified friend
*                  2) Obtain the text of the entire screen's sliding nodes
*                  3) Send 'Hello World' to designated friends and check if it was successfully sent
*/
function case3_test_list_scroll() {
  if (restart_test_app() == false) {
    print("case3_test_list_scroll Failed to start app");
  }
  var step1 = devices.clickSync("ci:List"); //Click on the List button, ci indicates no partition case
  if (step1.success() != true) {
    print("case3_test_list_scroll Execution failure: clicking the List button failed" + step1);
    return;
  }
  var step2 = devices.sendAai({ actions: ["scrollIntoView('T:Andy','down')"] }) //Auto scroll down to find Andy
  if (step2.success() != true) {
    print("case3_test_list_scroll Execution failed: did not scroll to the corresponding friend ");
    return false;
  }

  //Start clicking on friends and sending Hello World messages
  devices.sendAai({ query: "T:Andy", postAction: "click" })
  delay(3000)
  var step3 = devices.inputTextSync(0, "Hello World")
  if (step3.success() != true) {
    print("case3_test_list_scroll Execution failed: no input succeeded");
    return false;
  }
  devices.sendAai({ query: "C:.ImageView&&R:.btn_chat_message_send&&CC:0", postAction: "click" }) //Click on the send button

  //Check if Hello World is really in the conversation
  var getresult1 = devices.sendAai({ query: "TP:scrollable", action: "getText" })
  for (var i = 0; i < getresult1.length; i++) {
    var gettemp = getresult1[i].value;
    if (gettemp == -1) {
      print("case3_test_list_scroll Execution failed: not a scrollable interface");
      return false;
    } else {
      var getretval = gettemp.retval;
      var checkpoint = getretval.indexOf("Hello World");
      if (checkpoint == -1) {
        print("case3_test_list_scroll Execution failure: No corresponding friends found on the current interface");
        return false;
      }
    }
  }
  print("case3_test_list_scroll Execution successful");
}

/**
* TestCase 4: Test Multiple Input Box Input
*      Initial condition: Start the testing app
*      Test steps: 1) Enter information in the six input boxes of the FILED
*                  2) Submission Content
*                  3) Verify the input content
*/
function case4_test_mul_input() {
  if (restart_test_app() == false) {
    print("case4_test_mul_input Execution failure: Failed to start app");
  }
  var step1 = devices.clickSync("ci:EDITTEXT"); //Click the List button ci to indicate case insensitivity
  if (step1.success() != true) {
    print("case5_test_Seekbar Execution failure: clicking the SLIDER button failed" + step1);
    return;
  }
  var step1 = devices.inputTextSync(0, "1"); //Enter in the first input box
  var step2 = devices.inputTextSync(1, "2"); //Enter in the second  input box
  var step3 = devices.inputTextSync(2, "3"); //Enter in the third input box
  var step4 = devices.inputTextSync(3, "4"); //Enter in the fourth  input box
  var step5 = devices.inputTextSync(4, "5"); //Enter in the fifth input box
  var step6 = devices.inputTextSync(5, "6"); //Enter in the 6th  input box
  if (step1.success() != true || step2.success() != true || step3.success() != true || step4.success() != true || step5.success() != true || step6.success() != true) {
    print("case4_test_mul_input Execution failure: Input failure" + step1.output + "," + step2.output + "," + step3.output + "," + step4.output + "," + step5.output + "," + step6.output);
    return;
  }
  // Start submitting input information
  var step7 = devices.sendAai({ query: "T:ci:SUBMIT", action: "click" }); //submitCase insensitive
  if (step7.success() != true) {
    print("case4_test_mul_input Execution failure: SUBMIT failed");
    return false;
  }
  delay(2000)

  // Start checking the input content of the field
  for (var t = 1; t <= 6; t++) {
    var result = devices.sendAai({ query: "T:Field " + t + ":||OX:1", action: "getText" }).output //Obtain the content of the input box next to Filed 1, using ox offset to obtain
    for (var i = 0; i < result.length; i++) {
      var gettemp = result[i].value;
      if (gettemp == -1) {
        print("case4_test_mul_input Execution failed: no information obtained");
        return false;
      } else {
        var getretval = gettemp.retval;
        if (getretval != t) {
          print("case4_test_mul_input Execution failure: does not match the input contentt=" + t + ",retval=" + getretval);
          return false;
        }
      }
    }
  }
  print("case4_test_mul_input Execution successful");
}


/**
* TestCase 5: Test the sliding bar
*      Initial condition: Start the testing app
*      Test steps: 1) Enter the slider settings page
*                  2) Set the slider bar
*                  3) Verify the value acquisition of the slider
*/
function case5_test_Seekbar() {
  if (restart_test_app() == false) {
    print("case5_test_Seekbar Execution failure: Failed to start app");
  }
  var step1 = devices.clickSync("ci:SLIDER"); //Click on the SLIDER button
  if (step1.success() != true) {
    print("case5_test_Seekbar Execution failure: clicking the SLIDER button failed" + step1);
    return;
  }
  delay(3000)
  //Set the slider bar
  var setsliders = devices.sendAai({ query: "C:.SeekBar&&R:.seekBar_int&&CC:0", action: aaix("setProgress", 50) })
  if (step1.success() != true) {
    print("case5_test_Seekbar Execution failed: set value to" + step1.output);
    return;
  }
  delay(3000)
  //Obtain and verify the slider value
  var getsliders = devices.sendAai({ query: "C:.SeekBar&&R:.seekBar_int&&CC:0", action: "getProgress" })
  if (step1.success() != true) {
    print("case5_test_Seekbar Execution failed:Set the value to" + step1.output);
    return;
  }
  var getresult1 = getsliders.output;
  //Check if the previous value was actually set
  for (var i = 0; i < getresult1.length; i++) {
    var gettemp = getresult1[i].value;
    if (gettemp == -1) {
      print("case3_test_list_scroll Execution failure: Failed to obtain value");
      return false;
    } else {
      var getretval = gettemp.retval.current;
      if (getretval != 50) {
        print("case5_test_Seekbar Execution failure: incorrect sliding value obtained");
        return false;
      }
    }
  }
  print("case5_test_Seekbar Execution successful");
}

/**
* TestCase 6: Test Multiple Selection Box Selection
*      Initial condition: Start the testing app
*      Test steps: 1) Enter the multi selection box setting page
*                  2) Set up multiple selection boxes
*                  3) Obtain the value verification corresponding to the multiple selection box
*/
function case6_test_CheckBox() {
  if (restart_test_app() == false) {
    print("case6_test_CheckBox Execution failure: Failed to start app");
  }
  var step1 = devices.clickSync("ci:CHECKBOX"); //Click on the checkbox button to be case insensitive
  if (step1.success() != true) {
    print("case6_test_CheckBox Execution failure: clicking the SLIDER button failed" + step1);
    return;
  }
  delay(3000)
  //Tick the checkbox
  var setsliders = devices.sendAai({ query: "R:.checkbox1", action: "setChecked(true)" })
  if (step1.success() != true) {
    print("case6_test_CheckBox Execution failed: set value to" + step1.output);
    return;
  }
  delay(3000)
  //Obtain and verify the values of multiple selection boxes
  var getsliders = devices.sendAai({ action: "getChecked(R:.checkbox1)" })
  if (step1.success() != true) {
    print("case6_test_CheckBox Execution failed: set value to" + step1.output);
    return;
  }
  var getresult1 = getsliders.output;
  //Check if it is really the value set earlier
  for (var i = 0; i < getresult1.length; i++) {
    var gettemp = getresult1[i].value;
    if (gettemp == -1) {
      print("case3_test_list_scroll Execution failure: Failed to obtain value");
      return false;
    } else {
      var getretval = gettemp.retval;
      if (getretval != true) {
        print("case6_test_CheckBox Execution failed: the corresponding multi box status is incorrect");
        return false;
      }
    }
  }
  print("case6_test_CheckBox Execution successful");
}

case1_test_click();
case2_test_timeout_input();
case3_test_list_scroll();
case4_test_mul_input();
case5_test_Seekbar();
case6_test_CheckBox();



Script debugging

Total Control supports command line debug window for quick debugging.




Script Execution

Click the “Create Task to Execute” icon behind the script in the “Script” window.