com.opera.core.systems
Class ScopeServices

java.lang.Object
  extended by com.opera.core.systems.ScopeServices
All Implemented Interfaces:
IConnectionHandler

public class ScopeServices
extends java.lang.Object
implements IConnectionHandler

Implements the interface to the Scope protocol.

Author:
Deniz Turkoglu , Andreas Tolf Tolfsen

Constructor Summary
ScopeServices(java.util.Map<java.lang.String,java.lang.String> versions, int port, boolean manualConnect)
          Creates the Scope server on specified address and port, as well as enabling the required services for OperaDriver.
 
Method Summary
 void captureOperaIdle()
          Enables the capturing on OperaIdle events.
 void close()
          Close the connection and cleanup the channel
 void enableServices(java.util.List<java.lang.String> requiredServices)
           
 UmsProtos.Response executeCommand(ICommand command, com.google.protobuf.AbstractMessage.Builder<?> builder)
          Sends a command and wait for the response.
 UmsProtos.Response executeCommand(ICommand command, com.google.protobuf.AbstractMessage.Builder<?> builder, long timeout)
           
 StpConnection getConnection()
           
 ICookieManager getCookieManager()
           
 ICoreUtils getCoreUtils()
           
 IEcmaScriptDebugger getDebugger()
           
 IDesktopUtils getDesktopUtils()
           
 IDesktopWindowManager getDesktopWindowManager()
           
 IOperaExec getExec()
           
 java.util.List<java.lang.String> getListedServices()
           
 java.lang.String getMinVersionFor(java.lang.String service)
           
 IPrefs getPrefs()
           
 ISelftest getSelftest()
           
 SystemInputManager getSystemInputManager()
           
 java.util.Map<java.lang.String,java.lang.String> getVersions()
           
 IWindowManager getWindowManager()
           
 void init()
           
 boolean isOperaIdleAvailable()
           
 boolean onConnected(StpConnection con)
          This event is emitted if the STP connection thread has accepted a connection.
 void onDesktopWindowActivated(DesktopWmProtos.DesktopWindowInfo info)
           
 void onDesktopWindowClosed(DesktopWmProtos.DesktopWindowInfo info)
           
 void onDesktopWindowLoaded(DesktopWmProtos.DesktopWindowInfo info)
           
 void onDesktopWindowShown(DesktopWmProtos.DesktopWindowInfo info)
           
 void onDesktopWindowUpdated(DesktopWmProtos.DesktopWindowInfo info)
           
 void onDisconnect()
          This event is triggered whenever the STP connection is closed.
 void onException(java.lang.Exception ex)
          This event is triggered if an exception is thrown on the STP connection thread.
 void onHandshake(boolean stp1)
          This event is triggered when we have received a response to enableStp1().
 void onOperaIdle()
           
 void onQuickMenuClosed(DesktopWmProtos.QuickMenuID id)
           
 void onQuickMenuItemPressed(DesktopWmProtos.QuickMenuItemID menuItemID)
           
 void onQuickMenuShown(DesktopWmProtos.QuickMenuInfo info)
           
 void onRequest(int windowId)
           
 void onResponseReceived(int tag, UmsProtos.Response response)
          This event is triggered whenever a command error response is received.
 void onSelftestDone()
           
 void onSelftestOutput(SelftestProtos.SelftestOutput output)
           
 void onServiceList(java.util.List<java.lang.String> services)
          This event is triggered when the webdriver received an initial service list from Opera.
 void onWindowClosed(int id)
           
 void onWindowLoaded(int id)
           
 void quit()
           
 void quit(OperaRunner runner, int pid)
           
 void quitOpera(OperaRunner runner, int pid)
           
 java.lang.String selftest(java.util.List<java.lang.String> modules, long timeout)
           
 void setCookieManager(ICookieManager cookieManager)
           
 void setCoreUtils(ICoreUtils coreUtils)
           
 void setDebugger(IEcmaScriptDebugger debugger)
           
 void setDesktopUtils(IDesktopUtils desktopUtils)
           
 void setDesktopWindowManager(IDesktopWindowManager desktopWindowManager)
           
 void setExec(IOperaExec exec)
           
 void setListedServices(java.util.List<java.lang.String> services)
           
 void setPrefs(IPrefs prefs)
           
 void setProduct(java.lang.String product)
           
 void setSelftest(ISelftest selftest)
           
 void setSystemInputManager(SystemInputManager manager)
           
 void setWindowManager(IWindowManager windowManager)
           
 void shutdown()
           
 void startStpThread()
           
 int waitForDesktopWindowActivated(java.lang.String win_name, long timeout)
           
 int waitForDesktopWindowClosed(java.lang.String win_name, long timeout)
           
 int waitForDesktopWindowLoaded(java.lang.String win_name, long timeout)
           
 int waitForDesktopWindowShown(java.lang.String win_name, long timeout)
           
 int waitForDesktopWindowUpdated(java.lang.String win_name, long timeout)
           
 java.lang.String waitForMenuClosed(java.lang.String menuName, long timeout)
           
 java.lang.String waitForMenuItemPressed(java.lang.String menuItemText, long timeout)
           
 java.lang.String waitForMenuShown(java.lang.String menuName, long timeout)
           
 void waitForOperaIdle(long timeout)
          Waits for an OperaIdle event before continuing.
 void waitForWindowLoaded(int activeWindowId, long timeout)
           
 void waitStart()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScopeServices

public ScopeServices(java.util.Map<java.lang.String,java.lang.String> versions,
                     int port,
                     boolean manualConnect)
              throws java.io.IOException
Creates the Scope server on specified address and port, as well as enabling the required services for OperaDriver.

Throws:
java.io.IOException
Method Detail

getVersions

public java.util.Map<java.lang.String,java.lang.String> getVersions()

getConnection

public StpConnection getConnection()

getDebugger

public IEcmaScriptDebugger getDebugger()

setDebugger

public void setDebugger(IEcmaScriptDebugger debugger)

getExec

public IOperaExec getExec()

setExec

public void setExec(IOperaExec exec)

getWindowManager

public IWindowManager getWindowManager()

setWindowManager

public void setWindowManager(IWindowManager windowManager)

getCoreUtils

public ICoreUtils getCoreUtils()

setCoreUtils

public void setCoreUtils(ICoreUtils coreUtils)

getPrefs

public IPrefs getPrefs()

setPrefs

public void setPrefs(IPrefs prefs)

getDesktopWindowManager

public IDesktopWindowManager getDesktopWindowManager()

setDesktopWindowManager

public void setDesktopWindowManager(IDesktopWindowManager desktopWindowManager)

getDesktopUtils

public IDesktopUtils getDesktopUtils()

setDesktopUtils

public void setDesktopUtils(IDesktopUtils desktopUtils)

getSystemInputManager

public SystemInputManager getSystemInputManager()

setSystemInputManager

public void setSystemInputManager(SystemInputManager manager)

getCookieManager

public ICookieManager getCookieManager()

setCookieManager

public void setCookieManager(ICookieManager cookieManager)

getSelftest

public ISelftest getSelftest()

setSelftest

public void setSelftest(ISelftest selftest)

init

public void init()

shutdown

public void shutdown()

enableServices

public void enableServices(java.util.List<java.lang.String> requiredServices)

quitOpera

public void quitOpera(OperaRunner runner,
                      int pid)

quit

public void quit()

quit

public void quit(OperaRunner runner,
                 int pid)

onConnected

public boolean onConnected(StpConnection con)
Description copied from interface: IConnectionHandler
This event is emitted if the STP connection thread has accepted a connection. If an STP connection has already been accepted the return value can be used to close the newly accepted connection.

Specified by:
onConnected in interface IConnectionHandler
Parameters:
con - The connection that has been accepted.
Returns:
false if the connection should be closed immediately, or true to continue.

onServiceList

public void onServiceList(java.util.List<java.lang.String> services)
Description copied from interface: IConnectionHandler
This event is triggered when the webdriver received an initial service list from Opera.

Specified by:
onServiceList in interface IConnectionHandler

onWindowLoaded

public void onWindowLoaded(int id)

onWindowClosed

public void onWindowClosed(int id)

onDesktopWindowShown

public void onDesktopWindowShown(DesktopWmProtos.DesktopWindowInfo info)

onDesktopWindowUpdated

public void onDesktopWindowUpdated(DesktopWmProtos.DesktopWindowInfo info)

onDesktopWindowClosed

public void onDesktopWindowClosed(DesktopWmProtos.DesktopWindowInfo info)

onDesktopWindowActivated

public void onDesktopWindowActivated(DesktopWmProtos.DesktopWindowInfo info)

onDesktopWindowLoaded

public void onDesktopWindowLoaded(DesktopWmProtos.DesktopWindowInfo info)

onQuickMenuShown

public void onQuickMenuShown(DesktopWmProtos.QuickMenuInfo info)

onQuickMenuItemPressed

public void onQuickMenuItemPressed(DesktopWmProtos.QuickMenuItemID menuItemID)

onQuickMenuClosed

public void onQuickMenuClosed(DesktopWmProtos.QuickMenuID id)

onHandshake

public void onHandshake(boolean stp1)
Description copied from interface: IConnectionHandler
This event is triggered when we have received a response to enableStp1().

Specified by:
onHandshake in interface IConnectionHandler
Parameters:
stp1 - true if handshake was an STP/1 response.

onDisconnect

public void onDisconnect()
Description copied from interface: IConnectionHandler
This event is triggered whenever the STP connection is closed.

Specified by:
onDisconnect in interface IConnectionHandler

onOperaIdle

public void onOperaIdle()

onSelftestOutput

public void onSelftestOutput(SelftestProtos.SelftestOutput output)

onSelftestDone

public void onSelftestDone()

selftest

public java.lang.String selftest(java.util.List<java.lang.String> modules,
                                 long timeout)

waitForWindowLoaded

public void waitForWindowLoaded(int activeWindowId,
                                long timeout)

isOperaIdleAvailable

public boolean isOperaIdleAvailable()

captureOperaIdle

public void captureOperaIdle()
Enables the capturing on OperaIdle events. Sometimes when executing a command OperaIdle events will fire before the response is received for the sent command. This results in missing the Idle events, and later probably hitting a timeout. To prevent this you can call this function which will enable the tracking of any Idle events received between now and when you call waitForOperaIdle(). If Idle events have been received then waitForOperaIdle() will return immediately.


waitForOperaIdle

public void waitForOperaIdle(long timeout)
Waits for an OperaIdle event before continuing. If captureOperaIdle() has been called since the last call of waitForOperaIdle(), and one or more OperaIdle events have occurred then this function will return immediately. After calling this function the capturing of OperaIdle events is disabled until the next call of captureOperaIdle()

Parameters:
timeout - Time in milliseconds to wait before aborting

waitStart

public void waitStart()

waitForDesktopWindowLoaded

public int waitForDesktopWindowLoaded(java.lang.String win_name,
                                      long timeout)

waitForDesktopWindowShown

public int waitForDesktopWindowShown(java.lang.String win_name,
                                     long timeout)

waitForDesktopWindowUpdated

public int waitForDesktopWindowUpdated(java.lang.String win_name,
                                       long timeout)

waitForDesktopWindowActivated

public int waitForDesktopWindowActivated(java.lang.String win_name,
                                         long timeout)

waitForDesktopWindowClosed

public int waitForDesktopWindowClosed(java.lang.String win_name,
                                      long timeout)

waitForMenuShown

public java.lang.String waitForMenuShown(java.lang.String menuName,
                                         long timeout)

waitForMenuClosed

public java.lang.String waitForMenuClosed(java.lang.String menuName,
                                          long timeout)

waitForMenuItemPressed

public java.lang.String waitForMenuItemPressed(java.lang.String menuItemText,
                                               long timeout)

onResponseReceived

public void onResponseReceived(int tag,
                               UmsProtos.Response response)
Description copied from interface: IConnectionHandler
This event is triggered whenever a command error response is received.

Specified by:
onResponseReceived in interface IConnectionHandler
Parameters:
tag - the internal command tag corresponging to the request..
response - null if the response was an error.

onException

public void onException(java.lang.Exception ex)
Description copied from interface: IConnectionHandler
This event is triggered if an exception is thrown on the STP connection thread. Once this event has been triggered then the STP connection should be considered closed, and no further read/write operations are allowed.

Specified by:
onException in interface IConnectionHandler

getMinVersionFor

public java.lang.String getMinVersionFor(java.lang.String service)

setListedServices

public void setListedServices(java.util.List<java.lang.String> services)

getListedServices

public java.util.List<java.lang.String> getListedServices()

close

public void close()
Close the connection and cleanup the channel


executeCommand

public UmsProtos.Response executeCommand(ICommand command,
                                         com.google.protobuf.AbstractMessage.Builder<?> builder)
Sends a command and wait for the response.


executeCommand

public UmsProtos.Response executeCommand(ICommand command,
                                         com.google.protobuf.AbstractMessage.Builder<?> builder,
                                         long timeout)

startStpThread

public void startStpThread()

onRequest

public void onRequest(int windowId)

setProduct

public void setProduct(java.lang.String product)


Copyright © 2011. All Rights Reserved.