Update sdk/platform-tools to version 26.0.0.
[android_tools.git] / sdk / platform-tools / systrace / catapult / telemetry / telemetry / internal / app / android_app_unittest.py
blobf63b2e075018af67b2dec0ae7a123efdee523ae3
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.
5 import logging
6 import time
7 import unittest
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):
19 def setUp(self):
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.')
33 return
35 start_intent = intent.Intent(
36 package='com.google.android.googlequicksearchbox',
37 activity='.SearchActivity',
38 action='com.google.android.googlequicksearchbox.GOOGLE_SEARCH',
39 data=None,
40 extras={'query': 'google'},
41 category=None)
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:
51 return
53 webview = search_app.GetProcess(':search').GetWebViews().pop()
54 webview.Navigate('https://www.google.com/search?q=flowers')
55 time.sleep(5)