OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_TEST_CHROMEDRIVER_LOGGING_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_LOGGING_H_ |
6 #define CHROME_TEST_CHROMEDRIVER_LOGGING_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_LOGGING_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 // Creates a WebDriverLog with the given type and minimum level. | 32 // Creates a WebDriverLog with the given type and minimum level. |
33 WebDriverLog(const std::string& type, Level min_level); | 33 WebDriverLog(const std::string& type, Level min_level); |
34 virtual ~WebDriverLog(); | 34 virtual ~WebDriverLog(); |
35 | 35 |
36 // Returns entries accumulated so far, as a ListValue ready for serialization | 36 // Returns entries accumulated so far, as a ListValue ready for serialization |
37 // into the wire protocol response to the "/log" command. | 37 // into the wire protocol response to the "/log" command. |
38 // The caller assumes ownership of the ListValue, and the WebDriverLog | 38 // The caller assumes ownership of the ListValue, and the WebDriverLog |
39 // creates and owns a new empty ListValue for further accumulation. | 39 // creates and owns a new empty ListValue for further accumulation. |
40 scoped_ptr<base::ListValue> GetAndClearEntries(); | 40 scoped_ptr<base::ListValue> GetAndClearEntries(); |
41 | 41 |
| 42 // Finds the first error message in the log and returns it. If none exist, |
| 43 // returns an empty string. Does not clear entries. |
| 44 std::string GetFirstErrorMessage() const; |
| 45 |
42 // Translates a Log entry level into a WebDriver level and stores the entry. | 46 // Translates a Log entry level into a WebDriver level and stores the entry. |
43 virtual void AddEntryTimestamped(const base::Time& timestamp, | 47 virtual void AddEntryTimestamped(const base::Time& timestamp, |
44 Level level, | 48 Level level, |
45 const std::string& source, | 49 const std::string& source, |
46 const std::string& message) OVERRIDE; | 50 const std::string& message) OVERRIDE; |
47 | 51 |
48 const std::string& type() const; | 52 const std::string& type() const; |
49 void set_min_level(Level min_level); | 53 void set_min_level(Level min_level); |
50 Level min_level() const; | 54 Level min_level() const; |
51 | 55 |
52 private: | 56 private: |
53 const std::string type_; // WebDriver log type. | 57 const std::string type_; // WebDriver log type. |
54 Level min_level_; // Minimum level of entries to store. | 58 Level min_level_; // Minimum level of entries to store. |
55 scoped_ptr<base::ListValue> entries_; // Accumulated entries. | 59 scoped_ptr<base::ListValue> entries_; // Accumulated entries. |
56 | 60 |
57 DISALLOW_COPY_AND_ASSIGN(WebDriverLog); | 61 DISALLOW_COPY_AND_ASSIGN(WebDriverLog); |
58 }; | 62 }; |
59 | 63 |
60 // Initializes logging system for ChromeDriver. Returns true on success. | 64 // Initializes logging system for ChromeDriver. Returns true on success. |
61 bool InitLogging(); | 65 bool InitLogging(); |
62 | 66 |
63 // Creates Log's and DevToolsEventListener's based on logging preferences. | 67 // Creates Log's and DevToolsEventListener's based on logging preferences. |
64 Status CreateLogs(const Capabilities& capabilities, | 68 Status CreateLogs(const Capabilities& capabilities, |
65 ScopedVector<WebDriverLog>* out_logs, | 69 ScopedVector<WebDriverLog>* out_logs, |
66 ScopedVector<DevToolsEventListener>* out_listeners); | 70 ScopedVector<DevToolsEventListener>* out_listeners); |
67 | 71 |
68 #endif // CHROME_TEST_CHROMEDRIVER_LOGGING_H_ | 72 #endif // CHROME_TEST_CHROMEDRIVER_LOGGING_H_ |
OLD | NEW |