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 "content/shell/renderer/test_runner/test_runner.h" | 5 #include "content/shell/renderer/test_runner/test_runner.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/shell/common/test_runner/test_preferences.h" | 10 #include "content/shell/common/test_runner/test_preferences.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 void SetAlwaysAcceptCookies(bool accept); | 263 void SetAlwaysAcceptCookies(bool accept); |
264 void SetWindowIsKey(bool value); | 264 void SetWindowIsKey(bool value); |
265 std::string PathToLocalResource(const std::string& path); | 265 std::string PathToLocalResource(const std::string& path); |
266 void SetBackingScaleFactor(double value, v8::Handle<v8::Function> callback); | 266 void SetBackingScaleFactor(double value, v8::Handle<v8::Function> callback); |
267 void SetColorProfile(const std::string& name, | 267 void SetColorProfile(const std::string& name, |
268 v8::Handle<v8::Function> callback); | 268 v8::Handle<v8::Function> callback); |
269 void SetPOSIXLocale(const std::string& locale); | 269 void SetPOSIXLocale(const std::string& locale); |
270 void SetMIDIAccessorResult(bool result); | 270 void SetMIDIAccessorResult(bool result); |
271 void SetMIDISysexPermission(bool value); | 271 void SetMIDISysexPermission(bool value); |
272 void GrantWebNotificationPermission(gin::Arguments* args); | 272 void GrantWebNotificationPermission(gin::Arguments* args); |
| 273 void ClearWebNotificationPermissions(); |
273 bool SimulateWebNotificationClick(const std::string& value); | 274 bool SimulateWebNotificationClick(const std::string& value); |
274 void AddMockSpeechRecognitionResult(const std::string& transcript, | 275 void AddMockSpeechRecognitionResult(const std::string& transcript, |
275 double confidence); | 276 double confidence); |
276 void SetMockSpeechRecognitionError(const std::string& error, | 277 void SetMockSpeechRecognitionError(const std::string& error, |
277 const std::string& message); | 278 const std::string& message); |
278 bool WasMockSpeechRecognitionAborted(); | 279 bool WasMockSpeechRecognitionAborted(); |
279 void AddWebPageOverlay(); | 280 void AddWebPageOverlay(); |
280 void RemoveWebPageOverlay(); | 281 void RemoveWebPageOverlay(); |
281 void DisplayAsync(); | 282 void DisplayAsync(); |
282 void DisplayAsyncThen(v8::Handle<v8::Function> callback); | 283 void DisplayAsyncThen(v8::Handle<v8::Function> callback); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 .SetMethod("setBackingScaleFactor", | 507 .SetMethod("setBackingScaleFactor", |
507 &TestRunnerBindings::SetBackingScaleFactor) | 508 &TestRunnerBindings::SetBackingScaleFactor) |
508 .SetMethod("setColorProfile", &TestRunnerBindings::SetColorProfile) | 509 .SetMethod("setColorProfile", &TestRunnerBindings::SetColorProfile) |
509 .SetMethod("setPOSIXLocale", &TestRunnerBindings::SetPOSIXLocale) | 510 .SetMethod("setPOSIXLocale", &TestRunnerBindings::SetPOSIXLocale) |
510 .SetMethod("setMIDIAccessorResult", | 511 .SetMethod("setMIDIAccessorResult", |
511 &TestRunnerBindings::SetMIDIAccessorResult) | 512 &TestRunnerBindings::SetMIDIAccessorResult) |
512 .SetMethod("setMIDISysexPermission", | 513 .SetMethod("setMIDISysexPermission", |
513 &TestRunnerBindings::SetMIDISysexPermission) | 514 &TestRunnerBindings::SetMIDISysexPermission) |
514 .SetMethod("grantWebNotificationPermission", | 515 .SetMethod("grantWebNotificationPermission", |
515 &TestRunnerBindings::GrantWebNotificationPermission) | 516 &TestRunnerBindings::GrantWebNotificationPermission) |
| 517 .SetMethod("clearWebNotificationPermissions", |
| 518 &TestRunnerBindings::ClearWebNotificationPermissions) |
516 .SetMethod("simulateWebNotificationClick", | 519 .SetMethod("simulateWebNotificationClick", |
517 &TestRunnerBindings::SimulateWebNotificationClick) | 520 &TestRunnerBindings::SimulateWebNotificationClick) |
518 .SetMethod("addMockSpeechRecognitionResult", | 521 .SetMethod("addMockSpeechRecognitionResult", |
519 &TestRunnerBindings::AddMockSpeechRecognitionResult) | 522 &TestRunnerBindings::AddMockSpeechRecognitionResult) |
520 .SetMethod("setMockSpeechRecognitionError", | 523 .SetMethod("setMockSpeechRecognitionError", |
521 &TestRunnerBindings::SetMockSpeechRecognitionError) | 524 &TestRunnerBindings::SetMockSpeechRecognitionError) |
522 .SetMethod("wasMockSpeechRecognitionAborted", | 525 .SetMethod("wasMockSpeechRecognitionAborted", |
523 &TestRunnerBindings::WasMockSpeechRecognitionAborted) | 526 &TestRunnerBindings::WasMockSpeechRecognitionAborted) |
524 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) | 527 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) |
525 .SetMethod("removeWebPageOverlay", | 528 .SetMethod("removeWebPageOverlay", |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 if (runner_) | 1291 if (runner_) |
1289 runner_->SetMIDISysexPermission(value); | 1292 runner_->SetMIDISysexPermission(value); |
1290 } | 1293 } |
1291 | 1294 |
1292 void TestRunnerBindings::GrantWebNotificationPermission(gin::Arguments* args) { | 1295 void TestRunnerBindings::GrantWebNotificationPermission(gin::Arguments* args) { |
1293 if (runner_) { | 1296 if (runner_) { |
1294 std::string origin; | 1297 std::string origin; |
1295 bool permission_granted = true; | 1298 bool permission_granted = true; |
1296 args->GetNext(&origin); | 1299 args->GetNext(&origin); |
1297 args->GetNext(&permission_granted); | 1300 args->GetNext(&permission_granted); |
1298 return runner_->GrantWebNotificationPermission(origin, permission_granted); | 1301 return runner_->GrantWebNotificationPermission(GURL(origin), |
| 1302 permission_granted); |
1299 } | 1303 } |
1300 } | 1304 } |
1301 | 1305 |
| 1306 void TestRunnerBindings::ClearWebNotificationPermissions() { |
| 1307 if (runner_) |
| 1308 runner_->ClearWebNotificationPermissions(); |
| 1309 } |
| 1310 |
1302 bool TestRunnerBindings::SimulateWebNotificationClick( | 1311 bool TestRunnerBindings::SimulateWebNotificationClick( |
1303 const std::string& value) { | 1312 const std::string& value) { |
1304 if (runner_) | 1313 if (runner_) |
1305 return runner_->SimulateWebNotificationClick(value); | 1314 return runner_->SimulateWebNotificationClick(value); |
1306 return false; | 1315 return false; |
1307 } | 1316 } |
1308 | 1317 |
1309 void TestRunnerBindings::AddMockSpeechRecognitionResult( | 1318 void TestRunnerBindings::AddMockSpeechRecognitionResult( |
1310 const std::string& transcript, double confidence) { | 1319 const std::string& transcript, double confidence) { |
1311 if (runner_) | 1320 if (runner_) |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2722 midi_accessor_result_ = result; | 2731 midi_accessor_result_ = result; |
2723 } | 2732 } |
2724 | 2733 |
2725 void TestRunner::SetMIDISysexPermission(bool value) { | 2734 void TestRunner::SetMIDISysexPermission(bool value) { |
2726 const std::vector<WebTestProxyBase*>& windowList = | 2735 const std::vector<WebTestProxyBase*>& windowList = |
2727 test_interfaces_->windowList(); | 2736 test_interfaces_->windowList(); |
2728 for (unsigned i = 0; i < windowList.size(); ++i) | 2737 for (unsigned i = 0; i < windowList.size(); ++i) |
2729 windowList.at(i)->GetMIDIClientMock()->setSysexPermission(value); | 2738 windowList.at(i)->GetMIDIClientMock()->setSysexPermission(value); |
2730 } | 2739 } |
2731 | 2740 |
2732 void TestRunner::GrantWebNotificationPermission(const std::string& origin, | 2741 void TestRunner::GrantWebNotificationPermission(const GURL& origin, |
2733 bool permission_granted) { | 2742 bool permission_granted) { |
2734 notification_presenter_->GrantPermission(origin, permission_granted); | 2743 delegate_->grantWebNotificationPermission(origin, permission_granted); |
| 2744 } |
| 2745 |
| 2746 void TestRunner::ClearWebNotificationPermissions() { |
| 2747 delegate_->clearWebNotificationPermissions(); |
2735 } | 2748 } |
2736 | 2749 |
2737 bool TestRunner::SimulateWebNotificationClick(const std::string& value) { | 2750 bool TestRunner::SimulateWebNotificationClick(const std::string& value) { |
2738 return notification_presenter_->SimulateClick(value); | 2751 return notification_presenter_->SimulateClick(value); |
2739 } | 2752 } |
2740 | 2753 |
2741 void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript, | 2754 void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript, |
2742 double confidence) { | 2755 double confidence) { |
2743 proxy_->GetSpeechRecognizerMock()->addMockResult( | 2756 proxy_->GetSpeechRecognizerMock()->addMockResult( |
2744 WebString::fromUTF8(transcript), confidence); | 2757 WebString::fromUTF8(transcript), confidence); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2889 } | 2902 } |
2890 | 2903 |
2891 void TestRunner::DidLosePointerLockInternal() { | 2904 void TestRunner::DidLosePointerLockInternal() { |
2892 bool was_locked = pointer_locked_; | 2905 bool was_locked = pointer_locked_; |
2893 pointer_locked_ = false; | 2906 pointer_locked_ = false; |
2894 if (was_locked) | 2907 if (was_locked) |
2895 web_view_->didLosePointerLock(); | 2908 web_view_->didLosePointerLock(); |
2896 } | 2909 } |
2897 | 2910 |
2898 } // namespace content | 2911 } // namespace content |
OLD | NEW |