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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_test_api.h" 10 #include "chrome/browser/extensions/extension_test_api.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/test/ui_test_utils.h" 14 #include "chrome/test/ui_test_utils.h"
14 #include "content/common/notification_registrar.h" 15 #include "content/common/notification_registrar.h"
15 16
16 namespace { 17 namespace {
17 18
18 const char kTestServerPort[] = "testServer.port"; 19 const char kTestServerPort[] = "testServer.port";
19 20
20 }; // namespace 21 }; // namespace
21 22
22 ExtensionApiTest::ExtensionApiTest() {} 23 ExtensionApiTest::ExtensionApiTest() {}
23 24
24 ExtensionApiTest::~ExtensionApiTest() {} 25 ExtensionApiTest::~ExtensionApiTest() {}
25 26
26 ExtensionApiTest::ResultCatcher::ResultCatcher() 27 ExtensionApiTest::ResultCatcher::ResultCatcher()
27 : profile_restriction_(NULL), 28 : profile_restriction_(NULL),
28 waiting_(false) { 29 waiting_(false) {
29 registrar_.Add(this, NotificationType::EXTENSION_TEST_PASSED, 30 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_PASSED,
30 NotificationService::AllSources()); 31 NotificationService::AllSources());
31 registrar_.Add(this, NotificationType::EXTENSION_TEST_FAILED, 32 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_FAILED,
32 NotificationService::AllSources()); 33 NotificationService::AllSources());
33 } 34 }
34 35
35 ExtensionApiTest::ResultCatcher::~ResultCatcher() { 36 ExtensionApiTest::ResultCatcher::~ResultCatcher() {
36 } 37 }
37 38
38 bool ExtensionApiTest::ResultCatcher::GetNextResult() { 39 bool ExtensionApiTest::ResultCatcher::GetNextResult() {
39 // Depending on the tests, multiple results can come in from a single call 40 // Depending on the tests, multiple results can come in from a single call
40 // to RunMessageLoop(), so we maintain a queue of results and just pull them 41 // to RunMessageLoop(), so we maintain a queue of results and just pull them
41 // off as the test calls this, going to the run loop only when the queue is 42 // off as the test calls this, going to the run loop only when the queue is
(...skipping 10 matching lines...) Expand all
52 message_ = messages_.front(); 53 message_ = messages_.front();
53 messages_.pop_front(); 54 messages_.pop_front();
54 return ret; 55 return ret;
55 } 56 }
56 57
57 NOTREACHED(); 58 NOTREACHED();
58 return false; 59 return false;
59 } 60 }
60 61
61 void ExtensionApiTest::ResultCatcher::Observe( 62 void ExtensionApiTest::ResultCatcher::Observe(
62 NotificationType type, const NotificationSource& source, 63 int type, const NotificationSource& source,
63 const NotificationDetails& details) { 64 const NotificationDetails& details) {
64 if (profile_restriction_ && 65 if (profile_restriction_ &&
65 Source<Profile>(source).ptr() != profile_restriction_) { 66 Source<Profile>(source).ptr() != profile_restriction_) {
66 return; 67 return;
67 } 68 }
68 69
69 switch (type.value) { 70 switch (type) {
70 case NotificationType::EXTENSION_TEST_PASSED: 71 case chrome::NOTIFICATION_EXTENSION_TEST_PASSED:
71 VLOG(1) << "Got EXTENSION_TEST_PASSED notification."; 72 VLOG(1) << "Got EXTENSION_TEST_PASSED notification.";
72 results_.push_back(true); 73 results_.push_back(true);
73 messages_.push_back(""); 74 messages_.push_back("");
74 if (waiting_) 75 if (waiting_)
75 MessageLoopForUI::current()->Quit(); 76 MessageLoopForUI::current()->Quit();
76 break; 77 break;
77 78
78 case NotificationType::EXTENSION_TEST_FAILED: 79 case chrome::NOTIFICATION_EXTENSION_TEST_FAILED:
79 VLOG(1) << "Got EXTENSION_TEST_FAILED notification."; 80 VLOG(1) << "Got EXTENSION_TEST_FAILED notification.";
80 results_.push_back(false); 81 results_.push_back(false);
81 messages_.push_back(*(Details<std::string>(details).ptr())); 82 messages_.push_back(*(Details<std::string>(details).ptr()));
82 if (waiting_) 83 if (waiting_)
83 MessageLoopForUI::current()->Quit(); 84 MessageLoopForUI::current()->Quit();
84 break; 85 break;
85 86
86 default: 87 default:
87 NOTREACHED(); 88 NOTREACHED();
88 } 89 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 test_config_->SetInteger(kTestServerPort, 245 test_config_->SetInteger(kTestServerPort,
245 test_server()->host_port_pair().port()); 246 test_server()->host_port_pair().port());
246 247
247 return true; 248 return true;
248 } 249 }
249 250
250 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { 251 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) {
251 ExtensionBrowserTest::SetUpCommandLine(command_line); 252 ExtensionBrowserTest::SetUpCommandLine(command_line);
252 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); 253 test_data_dir_ = test_data_dir_.AppendASCII("api_test");
253 } 254 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_apitest.h ('k') | chrome/browser/extensions/extension_app_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698