1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
9 from telemetry
.core
import platform
as platform_module
10 from telemetry
.internal
.app
import android_app
11 from telemetry
.internal
.backends
import android_app_backend
12 from telemetry
.internal
.platform
import android_device
13 from telemetry
.testing
import options_for_unittests
15 from devil
.android
.sdk
import intent
18 class AndroidAppTest(unittest
.TestCase
):
20 self
._options
= options_for_unittests
.GetCopy()
21 self
._device
= android_device
.GetDevice(self
._options
)
23 def CreateAndroidApp(self
, start_intent
):
24 platform
= platform_module
.GetPlatformForDevice(self
._device
, self
._options
)
25 platform_backend
= platform
._platform
_backend
26 app_backend
= android_app_backend
.AndroidAppBackend(
27 platform_backend
, start_intent
)
28 return android_app
.AndroidApp(app_backend
, platform_backend
)
30 def testWebView(self
):
31 if self
._device
is None:
32 logging
.warning('No device found, skipping test.')
35 start_intent
= intent
.Intent(
36 package
='com.google.android.googlequicksearchbox',
37 activity
='.SearchActivity',
38 action
='com.google.android.googlequicksearchbox.GOOGLE_SEARCH',
40 extras
={'query': 'google'},
42 search_app
= self
.CreateAndroidApp(start_intent
)
43 search_process
= search_app
.GetProcess(':search')
44 search_process
._UpdateDevToolsClient
()
46 # TODO(ariblue): Replace the app used in this test with one in which the
47 # setWebContentsDebuggingEnabled method is called on the WebView class.
48 # This will configure webviews for debugging with chrome devtools inspector
49 # and allow us to remove this check.
50 if search_process
._devtools
_client
is None:
53 webview
= search_app
.GetProcess(':search').GetWebViews().pop()
54 webview
.Navigate('https://www.google.com/search?q=flowers')