Zooming In and Out Zoom Controls

Applies to TestComplete 14.60, last modified on April 22, 2021
Simulating Zoom In and Zoom Out Actions

To simulate zooming in or out, use the ZoomIn and ZoomOut actions of the Android ZoomControls object that TestComplete associates with that control. These actions simulate the specified number of touches on the zoom buttons of the zoom control.

The following example demonstrates how to use the methods to simulate zooming in and zooming out:

JavaScript, JScript

function Test()
{

  // Select the Android device
  Mobile.SetCurrent("MyDevice");

  // Obtain Zoom controls
  var p = Mobile.Device().Process("com.example.myapp");
  var v = p.RootLayout("").Layout("layoutTop").ScrollView("VerticalScrollView1");
  var Zoom = v.Layout("layout2").ZoomControls("zoomControls1");

  // Touch the zoom in button three times
  Zoom.ZoomIn(3);
  // Touch the zoom out button
  Zoom.ZoomOut();

}

Python

def Test():

  # Select the Android device
  Mobile.SetCurrent("MyDevice")

  # Obtain Zoom controls
  p = Mobile.Device().Process("com.example.myapp")
  v = p.RootLayout("").Layout("layoutTop").ScrollView("VerticalScrollView1")
  Zoom = v.Layout("layout2").ZoomControls("zoomControls1")

  # Touch the zoom in button three times
  Zoom.ZoomIn(3)
  # Touch the zoom out button
  Zoom.ZoomOut()

VBScript

Sub Test()

  ' Select the Android device
  Call Mobile.SetCurrent("MyDevice")

  ' Obtain Zoom controls
  Set p = Mobile.Device.Process("com.example.myapp")
  Set v = p.RootLayout("").Layout("layoutTop").ScrollView("VerticalScrollView1")
  Set Zoom = v.Layout("layout2").ZoomControls("zoomControls1")

  ' Touch the zoom in button three times
  Zoom.ZoomIn(3)
  ' Touch the zoom out button
  Zoom.ZoomOut

End Sub

DelphiScript

procedure Test();
var p, v, Zoom : OleVariant;
begin

  // Select the Android device
  Mobile.SetCurrent('MyDevice');

  // Obtain Zoom controls object
  p := Mobile.Device.Process('com.example.myapp');
  v := p.RootLayout('').Layout('layoutTop').ScrollView('VerticalScrollView1');
  Zoom := v.Layout('layout2').ZoomControls('zoomControls1');

  // Touch the zoom in button three times
  Zoom.ZoomIn(3);
  // Touch the zoom out button
  Zoom.ZoomIn;

end;

C++Script, C#Script

function Test()
{

  // Select the Android device
  Mobile["SetCurrent"]("MyDevice");

  // Obtain Zoom controls object
  var p = Mobile["Device"].Process("com.example.myapp");
  var v = p["RootLayout"]("")["Layout"]("layoutTop")["ScrollView"]("VerticalScrollView1");
  var Zoom = v["Layout"]("layout2")["ZoomControls"]("zoomControls1");

  // Touch the zoom in button three times
  Zoom["ZoomIn"](3);
  // Touch the zoom out button
  Zoom["ZoomOut"]();

}

Simulating Actions From Keyword Tests

This topic explains how to zoom in and out using the zoom control in scripts. You can use the described actions in keyword tests too. To do this, use the On-Screen Action or the Call Object Method operations.

See Also

Working With Android Zoom Controls Control
Android ZoomControls Methods

Highlight search results