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

Side by Side Diff: test/cctest/test-debug.cc

Issue 549057: Implement issue 554 Add "ProcessDebuggerRequests" call to Debug Agent API (Closed)
Patch Set: clean up Created 10 years, 11 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
« no previous file with comments | « src/execution.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5637 matching lines...) Expand 10 before | Expand all | Expand 10 after
5648 f->Call(env->Global(), 0, NULL); 5648 f->Call(env->Global(), 0, NULL);
5649 // There should be one more break event when the script is evaluated in 'f'. 5649 // There should be one more break event when the script is evaluated in 'f'.
5650 CHECK_EQ(2, break_point_hit_count); 5650 CHECK_EQ(2, break_point_hit_count);
5651 5651
5652 // Get rid of the debug message handler. 5652 // Get rid of the debug message handler.
5653 v8::Debug::SetMessageHandler2(NULL); 5653 v8::Debug::SetMessageHandler2(NULL);
5654 CheckDebuggerUnloaded(); 5654 CheckDebuggerUnloaded();
5655 } 5655 }
5656 5656
5657 5657
5658 static int counting_message_handler_counter;
5659
5660 static void CountingMessageHandler(const v8::Debug::Message& message) {
5661 counting_message_handler_counter++;
5662 }
5663
5664 // Test that debug messages get processed when ProcessDebugMessages is called.
5665 TEST(ProcessDebugMessages) {
5666 v8::HandleScope scope;
5667 DebugLocalContext env;
5668
5669 counting_message_handler_counter = 0;
5670
5671 v8::Debug::SetMessageHandler2(CountingMessageHandler);
5672
5673 const int kBufferSize = 1000;
5674 uint16_t buffer[kBufferSize];
5675 const char* scripts_command =
5676 "{\"seq\":0,"
5677 "\"type\":\"request\","
5678 "\"command\":\"scripts\"}";
5679
5680 // Send scripts command.
5681 v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
5682
5683 CHECK_EQ(0, counting_message_handler_counter);
5684 v8::Debug::ProcessDebugMessages();
5685 // At least one message should come
5686 CHECK_GE(counting_message_handler_counter, 1);
5687
5688 counting_message_handler_counter = 0;
5689
5690 v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
5691 v8::Debug::SendCommand(buffer, AsciiToUtf16(scripts_command, buffer));
5692 CHECK_EQ(0, counting_message_handler_counter);
5693 v8::Debug::ProcessDebugMessages();
5694 // At least two messages should come
5695 CHECK_GE(counting_message_handler_counter, 2);
5696
5697 // Get rid of the debug message handler.
5698 v8::Debug::SetMessageHandler2(NULL);
5699 CheckDebuggerUnloaded();
5700 }
5701
5702
5658 TEST(GetMirror) { 5703 TEST(GetMirror) {
5659 v8::HandleScope scope; 5704 v8::HandleScope scope;
5660 DebugLocalContext env; 5705 DebugLocalContext env;
5661 v8::Handle<v8::Value> obj = v8::Debug::GetMirror(v8::String::New("hodja")); 5706 v8::Handle<v8::Value> obj = v8::Debug::GetMirror(v8::String::New("hodja"));
5662 v8::Handle<v8::Function> run_test = v8::Handle<v8::Function>::Cast( 5707 v8::Handle<v8::Function> run_test = v8::Handle<v8::Function>::Cast(
5663 v8::Script::New( 5708 v8::Script::New(
5664 v8::String::New( 5709 v8::String::New(
5665 "function runTest(mirror) {" 5710 "function runTest(mirror) {"
5666 " return mirror.isString() && (mirror.length() == 5);" 5711 " return mirror.isString() && (mirror.length() == 5);"
5667 "}" 5712 "}"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5779 5824
5780 break_point_hit_count = 0; 5825 break_point_hit_count = 0;
5781 foo->Call(env->Global(), 0, NULL); 5826 foo->Call(env->Global(), 0, NULL);
5782 CHECK_EQ(1, break_point_hit_count); 5827 CHECK_EQ(1, break_point_hit_count);
5783 5828
5784 v8::Debug::SetDebugEventListener(NULL); 5829 v8::Debug::SetDebugEventListener(NULL);
5785 debugee_context = v8::Handle<v8::Context>(); 5830 debugee_context = v8::Handle<v8::Context>();
5786 debugger_context = v8::Handle<v8::Context>(); 5831 debugger_context = v8::Handle<v8::Context>();
5787 CheckDebuggerUnloaded(); 5832 CheckDebuggerUnloaded();
5788 } 5833 }
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698