ResetOrientation Method

Applies to TestComplete 14.91, last modified on July 20, 2021
The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach.

Description

The Mobile.Device.Desktop.ResetOrientation method resets the orientation of the mobile device to the default value.

Declaration

ProgObj.ResetOrientation()

ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section
Result Boolean

Applies To

The method is applied to the following object:

Result Value

True if the orientation was changes successfully; False otherwise.

Remarks

  • After the screen orientation is changed, some objects may no longer be visible, or the object position in the object browser may be changed.

  • ResetOrientation method is asynchronous. This means that TestComplete continues running the test, no matter whether the screen orientation has finished changing changed or not. This may cause some image-based tests to fail, since they start while the image is still changing. Object-based tests do not suffer from this issue.

  • After the screen orientation is changed, some objects may no longer be visible, or the object position in the object browser may be changed.

Example

The following example checks if the device is in portrait orientation and, if it is not, sets the orientation to default.

JavaScript, JScript

function Test()
{
  Mobile.SetCurrent("VirtualBox");

  var Desktop = Mobile.Device().Desktop;
  var Orientation = Desktop.GetOrientation();
  
  if (Orientation != soPortrait)
    Desktop.ResetOrientation();
}

Python

def Test():
  Mobile.SetCurrent("VirtualBox") 

  Desktop = Mobile.Device().Desktop 
  Orientation = Desktop.GetOrientation()
  
  if (Orientation != soPortrait):
    Desktop.ResetOrientation()

VBScript

Sub Test()
  Dim Desktop, Orientation

  Mobile.SetCurrent("VirtualBox")

  Set Desktop = Mobile.Device.Desktop
  Orientation = Desktop.GetOrientation()
  
  If Not Orientation = soPortrait Then
    Desktop.ResetOrientation
  End If
End Sub

DelphiScript

procedure Test();
var
  Desktop, Orientation;
begin
  Mobile.SetCurrent('VirtualBox');

  Desktop := Mobile.Device.Desktop;
  Orientation := Desktop.GetOrientation();
  
  if not Orientation = soPortrait then
    Desktop.ResetOrientation;
end;

C++Script, C#Script

function Test()
{
  Mobile["SetCurrent"]("VirtualBox");

  var Desktop = Mobile["Device"].Desktop;
  var Orientation = Desktop["GetOrientation"]();
  
  if (Orientation != soPortrait)
    Desktop["ResetOrientation"]();
}

See Also

Testing Android Applications (Legacy)
AndroidDesktop Object
SetOrientation Method
GetOrientation Method

Highlight search results