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 #include "extensions/browser/api/test/test_api.h" | 5 #include "extensions/browser/api/test/test_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "chrome/browser/chrome_notification_types.h" | |
12 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
13 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
14 #include "extensions/browser/extension_function_dispatcher.h" | 13 #include "extensions/browser/extension_function_dispatcher.h" |
15 #include "extensions/browser/extension_system.h" | 14 #include "extensions/browser/extension_system.h" |
| 15 #include "extensions/browser/notification_types.h" |
16 #include "extensions/common/api/test.h" | 16 #include "extensions/common/api/test.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // If you see this error in your test, you need to set the config state | 20 // If you see this error in your test, you need to set the config state |
21 // to be returned by chrome.test.getConfig(). Do this by calling | 21 // to be returned by chrome.test.getConfig(). Do this by calling |
22 // TestGetConfigFunction::set_test_config_state(Value* state) | 22 // TestGetConfigFunction::set_test_config_state(Value* state) |
23 // in test set up. | 23 // in test set up. |
24 const char kNoTestConfigDataError[] = "Test configuration was not set."; | 24 const char kNoTestConfigDataError[] = "Test configuration was not set."; |
25 | 25 |
(...skipping 16 matching lines...) Expand all Loading... |
42 error_ = kNotTestProcessError; | 42 error_ = kNotTestProcessError; |
43 return false; | 43 return false; |
44 } | 44 } |
45 return RunSafe(); | 45 return RunSafe(); |
46 } | 46 } |
47 | 47 |
48 TestNotifyPassFunction::~TestNotifyPassFunction() {} | 48 TestNotifyPassFunction::~TestNotifyPassFunction() {} |
49 | 49 |
50 bool TestNotifyPassFunction::RunSafe() { | 50 bool TestNotifyPassFunction::RunSafe() { |
51 content::NotificationService::current()->Notify( | 51 content::NotificationService::current()->Notify( |
52 chrome::NOTIFICATION_EXTENSION_TEST_PASSED, | 52 extensions::NOTIFICATION_EXTENSION_TEST_PASSED, |
53 content::Source<content::BrowserContext>(dispatcher()->browser_context()), | 53 content::Source<content::BrowserContext>(dispatcher()->browser_context()), |
54 content::NotificationService::NoDetails()); | 54 content::NotificationService::NoDetails()); |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 TestNotifyFailFunction::~TestNotifyFailFunction() {} | 58 TestNotifyFailFunction::~TestNotifyFailFunction() {} |
59 | 59 |
60 bool TestNotifyFailFunction::RunSafe() { | 60 bool TestNotifyFailFunction::RunSafe() { |
61 scoped_ptr<NotifyFail::Params> params(NotifyFail::Params::Create(*args_)); | 61 scoped_ptr<NotifyFail::Params> params(NotifyFail::Params::Create(*args_)); |
62 EXTENSION_FUNCTION_VALIDATE(params.get()); | 62 EXTENSION_FUNCTION_VALIDATE(params.get()); |
63 content::NotificationService::current()->Notify( | 63 content::NotificationService::current()->Notify( |
64 chrome::NOTIFICATION_EXTENSION_TEST_FAILED, | 64 extensions::NOTIFICATION_EXTENSION_TEST_FAILED, |
65 content::Source<content::BrowserContext>(dispatcher()->browser_context()), | 65 content::Source<content::BrowserContext>(dispatcher()->browser_context()), |
66 content::Details<std::string>(¶ms->message)); | 66 content::Details<std::string>(¶ms->message)); |
67 return true; | 67 return true; |
68 } | 68 } |
69 | 69 |
70 TestLogFunction::~TestLogFunction() {} | 70 TestLogFunction::~TestLogFunction() {} |
71 | 71 |
72 bool TestLogFunction::RunSafe() { | 72 bool TestLogFunction::RunSafe() { |
73 scoped_ptr<Log::Params> params(Log::Params::Create(*args_)); | 73 scoped_ptr<Log::Params> params(Log::Params::Create(*args_)); |
74 EXTENSION_FUNCTION_VALIDATE(params.get()); | 74 EXTENSION_FUNCTION_VALIDATE(params.get()); |
75 VLOG(1) << params->message; | 75 VLOG(1) << params->message; |
76 return true; | 76 return true; |
77 } | 77 } |
78 | 78 |
79 bool TestSendMessageFunction::RunAsync() { | 79 bool TestSendMessageFunction::RunAsync() { |
80 scoped_ptr<PassMessage::Params> params(PassMessage::Params::Create(*args_)); | 80 scoped_ptr<PassMessage::Params> params(PassMessage::Params::Create(*args_)); |
81 EXTENSION_FUNCTION_VALIDATE(params.get()); | 81 EXTENSION_FUNCTION_VALIDATE(params.get()); |
82 content::NotificationService::current()->Notify( | 82 content::NotificationService::current()->Notify( |
83 chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE, | 83 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, |
84 content::Source<TestSendMessageFunction>(this), | 84 content::Source<TestSendMessageFunction>(this), |
85 content::Details<std::string>(¶ms->message)); | 85 content::Details<std::string>(¶ms->message)); |
86 return true; | 86 return true; |
87 } | 87 } |
88 | 88 |
89 TestSendMessageFunction::~TestSendMessageFunction() {} | 89 TestSendMessageFunction::~TestSendMessageFunction() {} |
90 | 90 |
91 void TestSendMessageFunction::Reply(const std::string& message) { | 91 void TestSendMessageFunction::Reply(const std::string& message) { |
92 SetResult(new base::StringValue(message)); | 92 SetResult(new base::StringValue(message)); |
93 SendResponse(true); | 93 SendResponse(true); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 TestWaitForRoundTripFunction::~TestWaitForRoundTripFunction() {} | 131 TestWaitForRoundTripFunction::~TestWaitForRoundTripFunction() {} |
132 | 132 |
133 bool TestWaitForRoundTripFunction::RunSafe() { | 133 bool TestWaitForRoundTripFunction::RunSafe() { |
134 scoped_ptr<WaitForRoundTrip::Params> params( | 134 scoped_ptr<WaitForRoundTrip::Params> params( |
135 WaitForRoundTrip::Params::Create(*args_)); | 135 WaitForRoundTrip::Params::Create(*args_)); |
136 SetResult(new base::StringValue(params->message)); | 136 SetResult(new base::StringValue(params->message)); |
137 return true; | 137 return true; |
138 } | 138 } |
139 | 139 |
140 } // namespace extensions | 140 } // namespace extensions |
OLD | NEW |