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

Side by Side Diff: chrome/browser/extensions/extension_apitest.h

Issue 276010: Remove the implicit wrench menu items for browser actions. (Closed)
Patch Set: Rebase Created 11 years, 2 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
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_
7 7
8 #include "chrome/browser/extensions/extension_browsertest.h" 8 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/common/notification_service.h" 9 #include "chrome/common/notification_service.h"
10 10
11 // The general flow of these API tests should work like this: 11 // The general flow of these API tests should work like this:
12 // (1) Setup initial browser state (e.g. create some bookmarks for the 12 // (1) Setup initial browser state (e.g. create some bookmarks for the
13 // bookmark test) 13 // bookmark test)
14 // (2) Call ASSERT_TRUE(RunExtensionTest(name)); 14 // (2) Call ASSERT_TRUE(RunExtensionTest(name));
15 // (3) In your extension code, run your test and call chrome.test.pass or 15 // (3) In your extension code, run your test and call chrome.test.pass or
16 // chrome.test.fail 16 // chrome.test.fail
17 // (4) Verify expected browser state. 17 // (4) Verify expected browser state.
18 // TODO(erikkay): There should also be a way to drive events in these tests. 18 // TODO(erikkay): There should also be a way to drive events in these tests.
19 19
20 class ExtensionApiTest : public ExtensionBrowserTest { 20 class ExtensionApiTest : public ExtensionBrowserTest {
21 protected: 21 protected:
22 // Helper class that observes tests failing or passing. Observation starts whe n
23 // the class is constructed. Get the next result by calling GetNextResult() an d
24 // message() if GetNextResult() return false. If there are no results, this
25 // method will pump the UI message loop until one is received.
26 class ResultCatcher : public NotificationObserver {
27 public:
28 ResultCatcher();
29
30 // Pumps the UI loop until a notification is received that an API test
31 // succeeded or failed. Returns true if the test succeeded, false otherwise.
32 bool GetNextResult();
33
34 const std::string& message() { return message_; }
35
36 private:
37 virtual void Observe(NotificationType type, const NotificationSource& source ,
38 const NotificationDetails& details);
39
40 NotificationRegistrar registrar_;
41
42 // A sequential list of pass/fail notifications from the test extension(s).
43 std::deque<bool> results_;
44
45 // If it failed, what was the error message?
46 std::deque<std::string> messages_;
47 std::string message_;
48 };
49
22 // Load |extension_name| and wait for pass / fail notification. 50 // Load |extension_name| and wait for pass / fail notification.
23 // |extension_name| is a directory in "test/data/extensions/api_test". 51 // |extension_name| is a directory in "test/data/extensions/api_test".
24 bool RunExtensionTest(const char* extension_name); 52 bool RunExtensionTest(const char* extension_name);
25 53
26 // Reset |completed_| and wait for a new pass / fail notification.
27 bool WaitForPassFail();
28
29 // All extensions tested by ExtensionApiTest are in the "api_test" dir. 54 // All extensions tested by ExtensionApiTest are in the "api_test" dir.
30 virtual void SetUpCommandLine(CommandLine* command_line); 55 virtual void SetUpCommandLine(CommandLine* command_line);
31 56
32 // NotificationObserver
33 void Observe(NotificationType type, const NotificationSource& source,
34 const NotificationDetails& details);
35
36 // A sequential list of pass/fail notifications from the test extension(s).
37 std::deque<bool> results_;
38
39 // If it failed, what was the error message? 57 // If it failed, what was the error message?
40 std::deque<std::string> messages_;
41 std::string message_; 58 std::string message_;
42 }; 59 };
43 60
44 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ 61 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/browser_action_test.cc ('k') | chrome/browser/extensions/extension_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698