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

Side by Side Diff: components/test_runner/test_runner.cc

Issue 2373503003: Add clean up logic to navigator.credentials layout tests (Closed)
Patch Set: Created 4 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 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 "components/test_runner/test_runner.h" 5 #include "components/test_runner/test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 void SetWillSendRequestClearHeader(const std::string& header); 250 void SetWillSendRequestClearHeader(const std::string& header);
251 void SetWindowIsKey(bool value); 251 void SetWindowIsKey(bool value);
252 void SetXSSAuditorEnabled(bool enabled); 252 void SetXSSAuditorEnabled(bool enabled);
253 void ShowWebInspector(gin::Arguments* args); 253 void ShowWebInspector(gin::Arguments* args);
254 void SimulateWebNotificationClick(const std::string& title, int action_index); 254 void SimulateWebNotificationClick(const std::string& title, int action_index);
255 void SimulateWebNotificationClose(const std::string& title, bool by_user); 255 void SimulateWebNotificationClose(const std::string& title, bool by_user);
256 void UseUnfortunateSynchronousResizeMode(); 256 void UseUnfortunateSynchronousResizeMode();
257 void WaitForPolicyDelegate(); 257 void WaitForPolicyDelegate();
258 void WaitUntilDone(); 258 void WaitUntilDone();
259 void WaitUntilExternalURLLoad(); 259 void WaitUntilExternalURLLoad();
260 void AddMockCredentialManagerError(const std::string& error); 260 void SetMockCredentialManagerError(const std::string& error);
261 void AddMockCredentialManagerResponse(const std::string& id, 261 void SetMockCredentialManagerResponse(const std::string& id,
262 const std::string& name, 262 const std::string& name,
263 const std::string& avatar, 263 const std::string& avatar,
264 const std::string& password); 264 const std::string& password);
265 void ClearMockCredentialManagerResponse();
265 bool AnimationScheduled(); 266 bool AnimationScheduled();
266 bool CallShouldCloseOnWebView(); 267 bool CallShouldCloseOnWebView();
267 bool DisableAutoResizeMode(int new_width, int new_height); 268 bool DisableAutoResizeMode(int new_width, int new_height);
268 bool EnableAutoResizeMode(int min_width, 269 bool EnableAutoResizeMode(int min_width,
269 int min_height, 270 int min_height,
270 int max_width, 271 int max_width,
271 int max_height); 272 int max_height);
272 std::string EvaluateInWebInspectorOverlay(const std::string& script); 273 std::string EvaluateInWebInspectorOverlay(const std::string& script);
273 v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue( 274 v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue(
274 int world_id, const std::string& script); 275 int world_id, const std::string& script);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 base::WeakPtr<TestRunnerForSpecificView> view_runner) 330 base::WeakPtr<TestRunnerForSpecificView> view_runner)
330 : runner_(runner), view_runner_(view_runner) {} 331 : runner_(runner), view_runner_(view_runner) {}
331 332
332 TestRunnerBindings::~TestRunnerBindings() {} 333 TestRunnerBindings::~TestRunnerBindings() {}
333 334
334 gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder( 335 gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
335 v8::Isolate* isolate) { 336 v8::Isolate* isolate) {
336 return gin::Wrappable<TestRunnerBindings>::GetObjectTemplateBuilder(isolate) 337 return gin::Wrappable<TestRunnerBindings>::GetObjectTemplateBuilder(isolate)
337 .SetMethod("abortModal", &TestRunnerBindings::NotImplemented) 338 .SetMethod("abortModal", &TestRunnerBindings::NotImplemented)
338 .SetMethod("addDisallowedURL", &TestRunnerBindings::NotImplemented) 339 .SetMethod("addDisallowedURL", &TestRunnerBindings::NotImplemented)
339 .SetMethod("addMockCredentialManagerError", 340 .SetMethod("setMockCredentialManagerError",
340 &TestRunnerBindings::AddMockCredentialManagerError) 341 &TestRunnerBindings::SetMockCredentialManagerError)
341 .SetMethod("addMockCredentialManagerResponse", 342 .SetMethod("setMockCredentialManagerResponse",
342 &TestRunnerBindings::AddMockCredentialManagerResponse) 343 &TestRunnerBindings::SetMockCredentialManagerResponse)
344 .SetMethod("clearMockCredentialManagerResponse",
345 &TestRunnerBindings::ClearMockCredentialManagerResponse)
343 .SetMethod("addMockSpeechRecognitionResult", 346 .SetMethod("addMockSpeechRecognitionResult",
344 &TestRunnerBindings::AddMockSpeechRecognitionResult) 347 &TestRunnerBindings::AddMockSpeechRecognitionResult)
345 .SetMethod("addOriginAccessWhitelistEntry", 348 .SetMethod("addOriginAccessWhitelistEntry",
346 &TestRunnerBindings::AddOriginAccessWhitelistEntry) 349 &TestRunnerBindings::AddOriginAccessWhitelistEntry)
347 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) 350 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay)
348 .SetMethod("animationScheduled", &TestRunnerBindings::AnimationScheduled) 351 .SetMethod("animationScheduled", &TestRunnerBindings::AnimationScheduled)
349 .SetMethod("callShouldCloseOnWebView", 352 .SetMethod("callShouldCloseOnWebView",
350 &TestRunnerBindings::CallShouldCloseOnWebView) 353 &TestRunnerBindings::CallShouldCloseOnWebView)
351 .SetMethod("capturePixelsAsyncThen", 354 .SetMethod("capturePixelsAsyncThen",
352 &TestRunnerBindings::CapturePixelsAsyncThen) 355 &TestRunnerBindings::CapturePixelsAsyncThen)
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 if (runner_) 1372 if (runner_)
1370 runner_->AddMockSpeechRecognitionResult(transcript, confidence); 1373 runner_->AddMockSpeechRecognitionResult(transcript, confidence);
1371 } 1374 }
1372 1375
1373 void TestRunnerBindings::SetMockSpeechRecognitionError( 1376 void TestRunnerBindings::SetMockSpeechRecognitionError(
1374 const std::string& error, const std::string& message) { 1377 const std::string& error, const std::string& message) {
1375 if (runner_) 1378 if (runner_)
1376 runner_->SetMockSpeechRecognitionError(error, message); 1379 runner_->SetMockSpeechRecognitionError(error, message);
1377 } 1380 }
1378 1381
1379 void TestRunnerBindings::AddMockCredentialManagerResponse( 1382 void TestRunnerBindings::SetMockCredentialManagerResponse(
1380 const std::string& id, 1383 const std::string& id,
1381 const std::string& name, 1384 const std::string& name,
1382 const std::string& avatar, 1385 const std::string& avatar,
1383 const std::string& password) { 1386 const std::string& password) {
1384 if (runner_) 1387 if (runner_)
1385 runner_->AddMockCredentialManagerResponse(id, name, avatar, password); 1388 runner_->SetMockCredentialManagerResponse(id, name, avatar, password);
1386 } 1389 }
1387 1390
1388 void TestRunnerBindings::AddMockCredentialManagerError( 1391 void TestRunnerBindings::ClearMockCredentialManagerResponse() {
1392 if (runner_)
1393 runner_->ClearMockCredentialManagerResponse();
1394 }
1395
1396 void TestRunnerBindings::SetMockCredentialManagerError(
1389 const std::string& error) { 1397 const std::string& error) {
1390 if (runner_) 1398 if (runner_)
1391 runner_->AddMockCredentialManagerError(error); 1399 runner_->SetMockCredentialManagerError(error);
1392 } 1400 }
1393 1401
1394 void TestRunnerBindings::AddWebPageOverlay() { 1402 void TestRunnerBindings::AddWebPageOverlay() {
1395 if (view_runner_) 1403 if (view_runner_)
1396 view_runner_->AddWebPageOverlay(); 1404 view_runner_->AddWebPageOverlay();
1397 } 1405 }
1398 1406
1399 void TestRunnerBindings::RemoveWebPageOverlay() { 1407 void TestRunnerBindings::RemoveWebPageOverlay() {
1400 if (view_runner_) 1408 if (view_runner_)
1401 view_runner_->RemoveWebPageOverlay(); 1409 view_runner_->RemoveWebPageOverlay();
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2692 getMockWebSpeechRecognizer()->AddMockResult(WebString::fromUTF8(transcript), 2700 getMockWebSpeechRecognizer()->AddMockResult(WebString::fromUTF8(transcript),
2693 confidence); 2701 confidence);
2694 } 2702 }
2695 2703
2696 void TestRunner::SetMockSpeechRecognitionError(const std::string& error, 2704 void TestRunner::SetMockSpeechRecognitionError(const std::string& error,
2697 const std::string& message) { 2705 const std::string& message) {
2698 getMockWebSpeechRecognizer()->SetError(WebString::fromUTF8(error), 2706 getMockWebSpeechRecognizer()->SetError(WebString::fromUTF8(error),
2699 WebString::fromUTF8(message)); 2707 WebString::fromUTF8(message));
2700 } 2708 }
2701 2709
2702 void TestRunner::AddMockCredentialManagerResponse(const std::string& id, 2710 void TestRunner::SetMockCredentialManagerResponse(const std::string& id,
2703 const std::string& name, 2711 const std::string& name,
2704 const std::string& avatar, 2712 const std::string& avatar,
2705 const std::string& password) { 2713 const std::string& password) {
2706 credential_manager_client_->SetResponse(new WebPasswordCredential( 2714 credential_manager_client_->SetResponse(new WebPasswordCredential(
2707 WebString::fromUTF8(id), WebString::fromUTF8(password), 2715 WebString::fromUTF8(id), WebString::fromUTF8(password),
2708 WebString::fromUTF8(name), WebURL(GURL(avatar)))); 2716 WebString::fromUTF8(name), WebURL(GURL(avatar))));
2709 } 2717 }
2710 2718
2711 void TestRunner::AddMockCredentialManagerError(const std::string& error) { 2719 void TestRunner::ClearMockCredentialManagerResponse() {
2720 credential_manager_client_->SetResponse(nullptr);
2721 }
2722
2723 void TestRunner::SetMockCredentialManagerError(const std::string& error) {
2712 credential_manager_client_->SetError(error); 2724 credential_manager_client_->SetError(error);
2713 } 2725 }
2714 2726
2715 void TestRunner::OnLayoutTestRuntimeFlagsChanged() { 2727 void TestRunner::OnLayoutTestRuntimeFlagsChanged() {
2716 if (layout_test_runtime_flags_.tracked_dictionary().changed_values().empty()) 2728 if (layout_test_runtime_flags_.tracked_dictionary().changed_values().empty())
2717 return; 2729 return;
2718 if (!test_is_running_) 2730 if (!test_is_running_)
2719 return; 2731 return;
2720 2732
2721 delegate_->OnLayoutTestRuntimeFlagsChanged( 2733 delegate_->OnLayoutTestRuntimeFlagsChanged(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2758 2770
2759 void TestRunner::NotifyDone() { 2771 void TestRunner::NotifyDone() {
2760 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && 2772 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() &&
2761 !will_navigate_ && work_queue_.is_empty()) 2773 !will_navigate_ && work_queue_.is_empty())
2762 delegate_->TestFinished(); 2774 delegate_->TestFinished();
2763 layout_test_runtime_flags_.set_wait_until_done(false); 2775 layout_test_runtime_flags_.set_wait_until_done(false);
2764 OnLayoutTestRuntimeFlagsChanged(); 2776 OnLayoutTestRuntimeFlagsChanged();
2765 } 2777 }
2766 2778
2767 } // namespace test_runner 2779 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698