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

Side by Side Diff: test/cctest/test-cpu-profiler.cc

Issue 18336002: Test that profiler is stopped when isolate is being disposed (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated v8.h comments Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/cpu-profiler.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 const_cast<v8::CpuProfile*>(p2)->Delete(); 405 const_cast<v8::CpuProfile*>(p2)->Delete();
406 CHECK_EQ(1, cpu_profiler->GetProfileCount()); 406 CHECK_EQ(1, cpu_profiler->GetProfileCount());
407 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); 407 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2));
408 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); 408 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3));
409 const_cast<v8::CpuProfile*>(p3)->Delete(); 409 const_cast<v8::CpuProfile*>(p3)->Delete();
410 CHECK_EQ(0, cpu_profiler->GetProfileCount()); 410 CHECK_EQ(0, cpu_profiler->GetProfileCount());
411 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3)); 411 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3));
412 } 412 }
413 413
414 414
415 TEST(GetProfilerWhenIsolateIsNotInitialized) {
416 v8::Isolate* isolate = v8::Isolate::GetCurrent();
417 CHECK(i::Isolate::Current()->IsDefaultIsolate());
418 CHECK(!i::Isolate::Current()->IsInitialized());
419 CHECK_EQ(NULL, isolate->GetCpuProfiler());
420 {
421 v8::Isolate::Scope isolateScope(isolate);
422 LocalContext env;
423 v8::HandleScope scope(isolate);
424 CHECK_NE(NULL, isolate->GetCpuProfiler());
425 isolate->GetCpuProfiler()->StartCpuProfiling(v8::String::New("Test"));
426 isolate->GetCpuProfiler()->StopCpuProfiling(v8::String::New("Test"));
427 }
428 CHECK(i::Isolate::Current()->IsInitialized());
429 CHECK_NE(NULL, isolate->GetCpuProfiler());
430 isolate->Dispose();
431 CHECK_EQ(NULL, isolate->GetCpuProfiler());
432 }
433
434
415 static bool ContainsString(v8::Handle<v8::String> string, 435 static bool ContainsString(v8::Handle<v8::String> string,
416 const Vector<v8::Handle<v8::String> >& vector) { 436 const Vector<v8::Handle<v8::String> >& vector) {
417 for (int i = 0; i < vector.length(); i++) { 437 for (int i = 0; i < vector.length(); i++) {
418 if (string->Equals(vector[i])) 438 if (string->Equals(vector[i]))
419 return true; 439 return true;
420 } 440 }
421 return false; 441 return false;
422 } 442 }
423 443
424 444
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName); 978 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
959 names[2] = v8::String::New("start"); 979 names[2] = v8::String::New("start");
960 // Don't allow |foo| node to be at the top level. 980 // Don't allow |foo| node to be at the top level.
961 CheckChildrenNames(root, names); 981 CheckChildrenNames(root, names);
962 982
963 const v8::CpuProfileNode* startNode = GetChild(root, "start"); 983 const v8::CpuProfileNode* startNode = GetChild(root, "start");
964 GetChild(startNode, "foo"); 984 GetChild(startNode, "foo");
965 985
966 cpu_profiler->DeleteAllCpuProfiles(); 986 cpu_profiler->DeleteAllCpuProfiles();
967 } 987 }
OLDNEW
« no previous file with comments | « src/cpu-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698