| 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 EXTENSIONS_TEST_RESULT_CATCHER_H_ | 5 #ifndef EXTENSIONS_TEST_RESULT_CATCHER_H_ |
| 6 #define EXTENSIONS_TEST_RESULT_CATCHER_H_ | 6 #define EXTENSIONS_TEST_RESULT_CATCHER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 class BrowserContext; | 16 class BrowserContext; |
| 17 } // namespace content | 17 } // namespace content |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 | 20 |
| 21 // Helper class that observes tests failing or passing. Observation starts | 21 // Helper class that observes tests failing or passing. Observation starts |
| 22 // when the class is constructed. Get the next result by calling | 22 // when the class is constructed. Get the next result by calling |
| 23 // GetNextResult() and message() if GetNextResult() return false. If there | 23 // GetNextResult() and message() if GetNextResult() return false. If there |
| 24 // are no results, this method will pump the UI message loop until one is | 24 // are no results, this method will pump the UI message loop until one is |
| 25 // received. | 25 // received. |
| 26 // TODO(yoz): Replace the version in ExtensionApiTest with this. | |
| 27 class ResultCatcher : public content::NotificationObserver { | 26 class ResultCatcher : public content::NotificationObserver { |
| 28 public: | 27 public: |
| 29 ResultCatcher(); | 28 ResultCatcher(); |
| 30 virtual ~ResultCatcher(); | 29 virtual ~ResultCatcher(); |
| 31 | 30 |
| 32 // Pumps the UI loop until a notification is received that an API test | 31 // Pumps the UI loop until a notification is received that an API test |
| 33 // succeeded or failed. Returns true if the test succeeded, false otherwise. | 32 // succeeded or failed. Returns true if the test succeeded, false otherwise. |
| 34 bool GetNextResult(); | 33 bool GetNextResult(); |
| 35 | 34 |
| 36 void RestrictToBrowserContext(content::BrowserContext* context) { | 35 void RestrictToBrowserContext(content::BrowserContext* context) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 content::BrowserContext* browser_context_restriction_; | 57 content::BrowserContext* browser_context_restriction_; |
| 59 | 58 |
| 60 // True if we're in a nested message loop waiting for results from | 59 // True if we're in a nested message loop waiting for results from |
| 61 // the extension. | 60 // the extension. |
| 62 bool waiting_; | 61 bool waiting_; |
| 63 }; | 62 }; |
| 64 | 63 |
| 65 } // namespace extensions | 64 } // namespace extensions |
| 66 | 65 |
| 67 #endif // EXTENSIONS_TEST_RESULT_CATCHER_H_ | 66 #endif // EXTENSIONS_TEST_RESULT_CATCHER_H_ |
| OLD | NEW |