61d5a6b42e17d866564c1e93659ebab7c7558897
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / automation / tests / desktop / common.js
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.
4
5 var assertEq = chrome.test.assertEq;
6 var assertFalse = chrome.test.assertFalse;
7 var assertTrue = chrome.test.assertTrue;
8
9 var EventType = chrome.automation.EventType;
10 var RoleType = chrome.automation.RoleType;
11 var StateType = chrome.automation.StateType;
12
13 var rootNode = null;
14
15 function findAutomationNode(root, condition) {
16   if (condition(root))
17     return root;
18
19   var children = root.children();
20   for (var i = 0; i < children.length; i++) {
21     var result = findAutomationNode(children[i], condition);
22     if (result)
23       return result;
24   }
25   return null;
26 }
27
28 function setupAndRunTests(allTests) {
29   chrome.automation.getDesktop(function(rootNodeArg) {
30     rootNode = rootNodeArg;
31     chrome.test.runTests(allTests);
32   });
33 }