Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: extensions/test/result_catcher.h

Issue 529293003: Extract ResultCatcher from ExtensionApiTest. Use it in ShellApiTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 #ifndef EXTENSIONS_TEST_RESULT_CATCHER_H_
6 #define EXTENSIONS_TEST_RESULT_CATCHER_H_
7
8 #include <deque>
9 #include <string>
10
11 #include "base/compiler_specific.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14
15 namespace content {
16 class BrowserContext;
17 } // namespace content
18
19 namespace extensions {
20
21 // Helper class that observes tests failing or passing. Observation starts
James Cook 2014/09/03 18:08:42 What's the plan for ExtensionApiTest::ResultCatche
Yoyo Zhou 2014/09/04 21:57:42 It will be replaced with this one. Added a TODO.
22 // when the class is constructed. Get the next result by calling
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
25 // received.
26 class ResultCatcher : public content::NotificationObserver {
27 public:
28 ResultCatcher();
29 virtual ~ResultCatcher();
30
31 // Pumps the UI loop until a notification is received that an API test
32 // succeeded or failed. Returns true if the test succeeded, false otherwise.
33 bool GetNextResult();
34
35 void RestrictToBrowserContext(content::BrowserContext* context) {
36 context_restriction_ = context;
37 }
38
39 const std::string& message() { return message_; }
40
41 private:
42 virtual void Observe(int type,
James Cook 2014/09/03 18:08:42 Comment about which interface you are overriding
Yoyo Zhou 2014/09/04 21:57:42 Done.
43 const content::NotificationSource& source,
44 const content::NotificationDetails& details) OVERRIDE;
45
46 content::NotificationRegistrar registrar_;
47
48 // A sequential list of pass/fail notifications from the test extension(s).
49 std::deque<bool> results_;
50
51 // If it failed, what was the error message?
52 std::deque<std::string> messages_;
53 std::string message_;
54
55 // If non-NULL, we will listen to events from this BrowserContext only.
56 content::BrowserContext* context_restriction_;
James Cook 2014/09/03 18:08:42 it's horribly long but I would call this browser_c
Yoyo Zhou 2014/09/04 21:57:42 Done.
57
58 // True if we're in a nested message loop waiting for results from
59 // the extension.
60 bool waiting_;
61 };
62
63 } // namespace extensions
64
65 #endif // EXTENSIONS_TEST_RESULT_CATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698