| 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" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "extensions/browser/extension_function_dispatcher.h" | 14 #include "extensions/browser/extension_function_dispatcher.h" |
| 15 #include "extensions/browser/extension_system.h" | 15 #include "extensions/browser/extension_system.h" |
| 16 #include "extensions/browser/quota_service.h" | |
| 17 #include "extensions/common/api/test.h" | 16 #include "extensions/common/api/test.h" |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 // 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 |
| 22 // to be returned by chrome.test.getConfig(). Do this by calling | 21 // to be returned by chrome.test.getConfig(). Do this by calling |
| 23 // TestGetConfigFunction::set_test_config_state(Value* state) | 22 // TestGetConfigFunction::set_test_config_state(Value* state) |
| 24 // in test set up. | 23 // in test set up. |
| 25 const char kNoTestConfigDataError[] = "Test configuration was not set."; | 24 const char kNoTestConfigDataError[] = "Test configuration was not set."; |
| 26 | 25 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 69 |
| 71 TestLogFunction::~TestLogFunction() {} | 70 TestLogFunction::~TestLogFunction() {} |
| 72 | 71 |
| 73 bool TestLogFunction::RunSafe() { | 72 bool TestLogFunction::RunSafe() { |
| 74 scoped_ptr<Log::Params> params(Log::Params::Create(*args_)); | 73 scoped_ptr<Log::Params> params(Log::Params::Create(*args_)); |
| 75 EXTENSION_FUNCTION_VALIDATE(params.get()); | 74 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 76 VLOG(1) << params->message; | 75 VLOG(1) << params->message; |
| 77 return true; | 76 return true; |
| 78 } | 77 } |
| 79 | 78 |
| 80 TestResetQuotaFunction::~TestResetQuotaFunction() {} | |
| 81 | |
| 82 bool TestResetQuotaFunction::RunSafe() { | |
| 83 QuotaService* quota = | |
| 84 ExtensionSystem::Get(browser_context())->quota_service(); | |
| 85 quota->Purge(); | |
| 86 quota->violation_errors_.clear(); | |
| 87 return true; | |
| 88 } | |
| 89 | |
| 90 bool TestSendMessageFunction::RunAsync() { | 79 bool TestSendMessageFunction::RunAsync() { |
| 91 scoped_ptr<PassMessage::Params> params(PassMessage::Params::Create(*args_)); | 80 scoped_ptr<PassMessage::Params> params(PassMessage::Params::Create(*args_)); |
| 92 EXTENSION_FUNCTION_VALIDATE(params.get()); | 81 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 93 content::NotificationService::current()->Notify( | 82 content::NotificationService::current()->Notify( |
| 94 chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE, | 83 chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE, |
| 95 content::Source<TestSendMessageFunction>(this), | 84 content::Source<TestSendMessageFunction>(this), |
| 96 content::Details<std::string>(¶ms->message)); | 85 content::Details<std::string>(¶ms->message)); |
| 97 return true; | 86 return true; |
| 98 } | 87 } |
| 99 | 88 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 TestWaitForRoundTripFunction::~TestWaitForRoundTripFunction() {} | 126 TestWaitForRoundTripFunction::~TestWaitForRoundTripFunction() {} |
| 138 | 127 |
| 139 bool TestWaitForRoundTripFunction::RunSafe() { | 128 bool TestWaitForRoundTripFunction::RunSafe() { |
| 140 scoped_ptr<WaitForRoundTrip::Params> params( | 129 scoped_ptr<WaitForRoundTrip::Params> params( |
| 141 WaitForRoundTrip::Params::Create(*args_)); | 130 WaitForRoundTrip::Params::Create(*args_)); |
| 142 SetResult(new base::StringValue(params->message)); | 131 SetResult(new base::StringValue(params->message)); |
| 143 return true; | 132 return true; |
| 144 } | 133 } |
| 145 | 134 |
| 146 } // namespace extensions | 135 } // namespace extensions |
| OLD | NEW |