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

Unified Diff: test/cctest/test-heap-profiler.cc

Issue 6580038: [Isolates] Merge from bleeding_edge, revisions 5934-6100. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap-profiler.cc
===================================================================
--- test/cctest/test-heap-profiler.cc (revision 6904)
+++ test/cctest/test-heap-profiler.cc (working copy)
@@ -1211,4 +1211,51 @@
CHECK_EQ(NULL, snapshot->GetNodeById(0x1000000UL));
}
+
+namespace {
+
+class TestActivityControl : public v8::ActivityControl {
+ public:
+ explicit TestActivityControl(int abort_count)
+ : done_(0), total_(0), abort_count_(abort_count) {}
+ ControlOption ReportProgressValue(int done, int total) {
+ done_ = done;
+ total_ = total;
+ return --abort_count_ != 0 ? kContinue : kAbort;
+ }
+ int done() { return done_; }
+ int total() { return total_; }
+
+ private:
+ int done_;
+ int total_;
+ int abort_count_;
+};
+}
+
+TEST(TakeHeapSnapshotAborting) {
+ v8::HandleScope scope;
+ LocalContext env;
+
+ const int snapshots_count = v8::HeapProfiler::GetSnapshotsCount();
+ TestActivityControl aborting_control(3);
+ const v8::HeapSnapshot* no_snapshot =
+ v8::HeapProfiler::TakeSnapshot(v8::String::New("abort"),
+ v8::HeapSnapshot::kFull,
+ &aborting_control);
+ CHECK_EQ(NULL, no_snapshot);
+ CHECK_EQ(snapshots_count, v8::HeapProfiler::GetSnapshotsCount());
+ CHECK_GT(aborting_control.total(), aborting_control.done());
+
+ TestActivityControl control(-1); // Don't abort.
+ const v8::HeapSnapshot* snapshot =
+ v8::HeapProfiler::TakeSnapshot(v8::String::New("full"),
+ v8::HeapSnapshot::kFull,
+ &control);
+ CHECK_NE(NULL, snapshot);
+ CHECK_EQ(snapshots_count + 1, v8::HeapProfiler::GetSnapshotsCount());
+ CHECK_EQ(control.total(), control.done());
+ CHECK_GT(control.total(), 0);
+}
+
#endif // ENABLE_LOGGING_AND_PROFILING
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698