Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / test / chromedriver / util.h
1 // Copyright (c) 2013 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 #ifndef CHROME_TEST_CHROMEDRIVER_UTIL_H_
6 #define CHROME_TEST_CHROMEDRIVER_UTIL_H_
7
8 #include <string>
9
10 namespace base {
11 class FilePath;
12 class ListValue;
13 }
14
15 struct Session;
16 class Status;
17 class WebView;
18
19 // Generates a random, 32-character hexidecimal ID.
20 std::string GenerateId();
21
22 // Send a sequence of key strokes to the active Element in window.
23 Status SendKeysOnWindow(
24     WebView* web_view,
25     const base::ListValue* key_list,
26     bool release_modifiers,
27     int* sticky_modifiers);
28
29 // Decodes the given base64-encoded string, after removing any newlines,
30 // which are required in some base64 standards. Returns true on success.
31 bool Base64Decode(const std::string& base64, std::string* bytes);
32
33 // Unzips the sole file contained in the given zip data |bytes| into
34 // |unzip_dir|. The zip data may be a normal zip archive or a single zip file
35 // entry. If the unzip successfully produced one file, returns true and sets
36 // |file| to the unzipped file.
37 // TODO(kkania): Remove the ability to parse single zip file entries when
38 // the current versions of all WebDriver clients send actual zip files.
39 Status UnzipSoleFile(const base::FilePath& unzip_dir,
40                      const std::string& bytes,
41                      base::FilePath* file);
42
43 // Calls BeforeCommand for each of |session|'s |CommandListener|s.
44 // If an error is encountered, will mark |session| for deletion and return.
45 Status NotifyCommandListenersBeforeCommand(Session* session,
46                                            const std::string& command_name);
47
48 #endif  // CHROME_TEST_CHROMEDRIVER_UTIL_H_