OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_PUBLIC_TEST_JAVASCRIPT_TEST_OBSERVER_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_JAVASCRIPT_TEST_OBSERVER_H_ |
6 #define CONTENT_PUBLIC_TEST_JAVASCRIPT_TEST_OBSERVER_H_ | 6 #define CONTENT_PUBLIC_TEST_JAVASCRIPT_TEST_OBSERVER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 // This class captures a stream of automation messages coming from a Javascript | 56 // This class captures a stream of automation messages coming from a Javascript |
57 // test and dispatches them to a message handler. | 57 // test and dispatches them to a message handler. |
58 class JavascriptTestObserver : public NotificationObserver { | 58 class JavascriptTestObserver : public NotificationObserver { |
59 public: | 59 public: |
60 // The observer does not own any arguments passed to it. It is assumed that | 60 // The observer does not own any arguments passed to it. It is assumed that |
61 // the arguments will outlive all uses of the observer. | 61 // the arguments will outlive all uses of the observer. |
62 JavascriptTestObserver(WebContents* web_contents, | 62 JavascriptTestObserver(WebContents* web_contents, |
63 TestMessageHandler* handler); | 63 TestMessageHandler* handler); |
64 | 64 |
65 virtual ~JavascriptTestObserver(); | 65 ~JavascriptTestObserver() override; |
66 | 66 |
67 // Pump the message loop until the message handler indicates the Javascript | 67 // Pump the message loop until the message handler indicates the Javascript |
68 // test is done running. Return true if the test jig functioned correctly and | 68 // test is done running. Return true if the test jig functioned correctly and |
69 // nothing timed out. | 69 // nothing timed out. |
70 bool Run(); | 70 bool Run(); |
71 | 71 |
72 // Prepare the observer to be used again. This method should NOT be called | 72 // Prepare the observer to be used again. This method should NOT be called |
73 // while Run() is pumping the message loop. | 73 // while Run() is pumping the message loop. |
74 void Reset(); | 74 void Reset(); |
75 | 75 |
76 virtual void Observe( | 76 void Observe(int type, |
77 int type, | 77 const NotificationSource& source, |
78 const NotificationSource& source, | 78 const NotificationDetails& details) override; |
79 const NotificationDetails& details) override; | |
80 | 79 |
81 private: | 80 private: |
82 // This message did not signal the end of a test, keep going. | 81 // This message did not signal the end of a test, keep going. |
83 void Continue(); | 82 void Continue(); |
84 | 83 |
85 // This was the last message we care about, stop listening for more messages. | 84 // This was the last message we care about, stop listening for more messages. |
86 void EndTest(); | 85 void EndTest(); |
87 | 86 |
88 TestMessageHandler* handler_; | 87 TestMessageHandler* handler_; |
89 bool running_; | 88 bool running_; |
90 bool finished_; | 89 bool finished_; |
91 NotificationRegistrar registrar_; | 90 NotificationRegistrar registrar_; |
92 | 91 |
93 DISALLOW_COPY_AND_ASSIGN(JavascriptTestObserver); | 92 DISALLOW_COPY_AND_ASSIGN(JavascriptTestObserver); |
94 }; | 93 }; |
95 | 94 |
96 } // namespace content | 95 } // namespace content |
97 | 96 |
98 #endif // CONTENT_PUBLIC_TEST_JAVASCRIPT_TEST_OBSERVER_H_ | 97 #endif // CONTENT_PUBLIC_TEST_JAVASCRIPT_TEST_OBSERVER_H_ |
OLD | NEW |