• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Chromium OS 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.
4
5import os
6
7from autotest_lib.client.bin import test, utils
8from autotest_lib.client.common_lib import error
9from autotest_lib.client.common_lib.cros import chrome
10
11
12class desktopui_CameraApp(test.test):
13    """Tests if the Camera App works correctly."""
14    version = 1
15    preserve_srcdir = True
16
17
18    def setup(self):
19        """Fetches and builds the ToT Camera App."""
20        os.chdir(self.srcdir)
21        utils.make('clean')
22        utils.make('all')
23
24
25    def run_once(self):
26        """Runs the integration test."""
27        # Create the browser instance.
28        camera_path = os.path.join(os.path.dirname(__file__),
29                                   'src/camera/build/camera')
30        browser = chrome.Chrome(extension_paths=[camera_path],
31                                is_component=False)
32
33        # Start the Camera app.
34        extension = browser.get_extension(camera_path)
35        extension.ExecuteJavaScript('camera.bg.createForTesting();')
36
37        # Wait until the Camera app acquires the stream.
38        js_is_capturing = (
39                'camera.bg.appWindow && '
40                'camera.bg.appWindow.contentWindow.camera && '
41                'camera.bg.appWindow.contentWindow.camera.Camera && '
42                'camera.bg.appWindow.contentWindow.camera.Camera.getInstance().'
43                'cameraView.capturing')
44
45        # Verify if the camera initializes correctly in up to 30 seconds.
46        utils.poll_for_condition(
47                condition=lambda: extension.EvaluateJavaScript(js_is_capturing),
48                exception=error.TestError('Camera initialization timed out.'),
49                sleep_interval=1,
50                timeout=30)
51
52