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

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

Issue 16114002: Deprecate profiler methods that accept security origin (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: defined V8_DISABLE_DEPRECATIONS in test-cpu-profiler.cc and returned deleted test for deprecated API Created 7 years, 6 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/api.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | 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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 // 27 //
28 // Tests of profiles generator and utilities. 28 // Tests of profiles generator and utilities.
29 29
30 // TODO(dcarney): remove 30 // TODO(dcarney): remove
31 #define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW 31 #define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
32 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT 32 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
33 33
34 #define V8_DISABLE_DEPRECATIONS 1
34 #include "v8.h" 35 #include "v8.h"
35 #include "cpu-profiler-inl.h" 36 #include "cpu-profiler-inl.h"
36 #include "cctest.h" 37 #include "cctest.h"
37 #include "utils.h" 38 #include "utils.h"
38 #include "../include/v8-profiler.h" 39 #include "../include/v8-profiler.h"
40 #undef V8_DISABLE_DEPRECATIONS
39 41
40 using i::CodeEntry; 42 using i::CodeEntry;
41 using i::CpuProfile; 43 using i::CpuProfile;
42 using i::CpuProfiler; 44 using i::CpuProfiler;
43 using i::CpuProfilesCollection; 45 using i::CpuProfilesCollection;
44 using i::ProfileGenerator; 46 using i::ProfileGenerator;
45 using i::ProfileNode; 47 using i::ProfileNode;
46 using i::ProfilerEventsProcessor; 48 using i::ProfilerEventsProcessor;
47 using i::ScopedVector; 49 using i::ScopedVector;
48 using i::TokenEnumerator; 50 using i::TokenEnumerator;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 292
291 // Test profiling cancellation by the 'delete' command. 293 // Test profiling cancellation by the 'delete' command.
292 profiler->StartProfiling("1"); 294 profiler->StartProfiling("1");
293 profiler->StartProfiling("2"); 295 profiler->StartProfiling("2");
294 CHECK_EQ(0, profiler->GetProfilesCount()); 296 CHECK_EQ(0, profiler->GetProfilesCount());
295 profiler->DeleteAllProfiles(); 297 profiler->DeleteAllProfiles();
296 CHECK_EQ(0, profiler->GetProfilesCount()); 298 CHECK_EQ(0, profiler->GetProfilesCount());
297 } 299 }
298 300
299 301
302 static const v8::CpuProfile* FindCpuProfile(v8::CpuProfiler* profiler,
303 unsigned uid) {
304 int length = profiler->GetProfileCount();
305 for (int i = 0; i < length; i++) {
306 const v8::CpuProfile* profile = profiler->GetCpuProfile(i);
307 if (profile->GetUid() == uid) {
308 return profile;
309 }
310 }
311 return NULL;
312 }
313
314
300 TEST(DeleteCpuProfile) { 315 TEST(DeleteCpuProfile) {
301 LocalContext env; 316 LocalContext env;
302 v8::HandleScope scope(env->GetIsolate()); 317 v8::HandleScope scope(env->GetIsolate());
303 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 318 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
304 319
305 CHECK_EQ(0, cpu_profiler->GetProfileCount()); 320 CHECK_EQ(0, cpu_profiler->GetProfileCount());
306 v8::Local<v8::String> name1 = v8::String::New("1"); 321 v8::Local<v8::String> name1 = v8::String::New("1");
307 cpu_profiler->StartCpuProfiling(name1); 322 cpu_profiler->StartCpuProfiling(name1);
308 const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1); 323 const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1);
309 CHECK_NE(NULL, p1); 324 CHECK_NE(NULL, p1);
310 CHECK_EQ(1, cpu_profiler->GetProfileCount()); 325 CHECK_EQ(1, cpu_profiler->GetProfileCount());
311 unsigned uid1 = p1->GetUid(); 326 unsigned uid1 = p1->GetUid();
312 CHECK_EQ(p1, cpu_profiler->FindCpuProfile(uid1)); 327 CHECK_EQ(p1, FindCpuProfile(cpu_profiler, uid1));
313 const_cast<v8::CpuProfile*>(p1)->Delete(); 328 const_cast<v8::CpuProfile*>(p1)->Delete();
314 CHECK_EQ(0, cpu_profiler->GetProfileCount()); 329 CHECK_EQ(0, cpu_profiler->GetProfileCount());
315 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); 330 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
316 331
317 v8::Local<v8::String> name2 = v8::String::New("2"); 332 v8::Local<v8::String> name2 = v8::String::New("2");
318 cpu_profiler->StartCpuProfiling(name2); 333 cpu_profiler->StartCpuProfiling(name2);
319 const v8::CpuProfile* p2 = cpu_profiler->StopCpuProfiling(name2); 334 const v8::CpuProfile* p2 = cpu_profiler->StopCpuProfiling(name2);
320 CHECK_NE(NULL, p2); 335 CHECK_NE(NULL, p2);
321 CHECK_EQ(1, cpu_profiler->GetProfileCount()); 336 CHECK_EQ(1, cpu_profiler->GetProfileCount());
322 unsigned uid2 = p2->GetUid(); 337 unsigned uid2 = p2->GetUid();
323 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); 338 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
324 CHECK_EQ(p2, cpu_profiler->FindCpuProfile(uid2)); 339 CHECK_EQ(p2, FindCpuProfile(cpu_profiler, uid2));
325 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); 340 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
326 v8::Local<v8::String> name3 = v8::String::New("3"); 341 v8::Local<v8::String> name3 = v8::String::New("3");
327 cpu_profiler->StartCpuProfiling(name3); 342 cpu_profiler->StartCpuProfiling(name3);
328 const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3); 343 const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3);
329 CHECK_NE(NULL, p3); 344 CHECK_NE(NULL, p3);
330 CHECK_EQ(2, cpu_profiler->GetProfileCount()); 345 CHECK_EQ(2, cpu_profiler->GetProfileCount());
331 unsigned uid3 = p3->GetUid(); 346 unsigned uid3 = p3->GetUid();
332 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); 347 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
333 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); 348 CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3));
334 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); 349 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
335 const_cast<v8::CpuProfile*>(p2)->Delete(); 350 const_cast<v8::CpuProfile*>(p2)->Delete();
336 CHECK_EQ(1, cpu_profiler->GetProfileCount()); 351 CHECK_EQ(1, cpu_profiler->GetProfileCount());
337 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); 352 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2));
338 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); 353 CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3));
339 const_cast<v8::CpuProfile*>(p3)->Delete(); 354 const_cast<v8::CpuProfile*>(p3)->Delete();
340 CHECK_EQ(0, cpu_profiler->GetProfileCount()); 355 CHECK_EQ(0, cpu_profiler->GetProfileCount());
341 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3)); 356 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid3));
342 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); 357 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2));
343 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); 358 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
344 } 359 }
345 360
346 361
347 TEST(DeleteCpuProfileDifferentTokens) { 362 TEST(DeleteCpuProfileDifferentTokens) {
348 LocalContext env; 363 LocalContext env;
349 v8::HandleScope scope(env->GetIsolate()); 364 v8::HandleScope scope(env->GetIsolate());
350 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 365 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
351 366
352 CHECK_EQ(0, cpu_profiler->GetProfileCount()); 367 CHECK_EQ(0, cpu_profiler->GetProfileCount());
353 v8::Local<v8::String> name1 = v8::String::New("1"); 368 v8::Local<v8::String> name1 = v8::String::New("1");
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 CHECK_EQ(1, startNode->GetChildrenCount()); 635 CHECK_EQ(1, startNode->GetChildrenCount());
621 const v8::CpuProfileNode* delayNode = GetChild(startNode, "delay"); 636 const v8::CpuProfileNode* delayNode = GetChild(startNode, "delay");
622 if (delayNode->GetChildrenCount() > 0) { 637 if (delayNode->GetChildrenCount() > 0) {
623 CHECK_EQ(1, delayNode->GetChildrenCount()); 638 CHECK_EQ(1, delayNode->GetChildrenCount());
624 GetChild(delayNode, "loop"); 639 GetChild(delayNode, "loop");
625 } 640 }
626 } 641 }
627 642
628 cpu_profiler->DeleteAllCpuProfiles(); 643 cpu_profiler->DeleteAllCpuProfiles();
629 } 644 }
OLDNEW
« no previous file with comments | « src/api.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698