From d6918e3c8faf5e445950402f7ea56233dd800948 Mon Sep 17 00:00:00 2001 From: Richard Uhler Date: Wed, 14 Jun 2017 16:42:44 +0100 Subject: ahat: Improve field diffing. * Factor field diffing code out of Diff into its own class. * Switch to a new interface for diffing fields that does not rely on being passed mutable lists. * Reimplement field diff to work better when fields have been added, deleted, or reordered. Bug: 62408050 Test: m ahat-test, with new tests for field diff added. Change-Id: I56c0414f8f4c11809895d809494d752201d33563 --- tools/ahat/test/DiffTest.java | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'tools/ahat/test/DiffTest.java') diff --git a/tools/ahat/test/DiffTest.java b/tools/ahat/test/DiffTest.java index 52b6b7b3ae..d0349fd178 100644 --- a/tools/ahat/test/DiffTest.java +++ b/tools/ahat/test/DiffTest.java @@ -20,7 +20,6 @@ import com.android.ahat.heapdump.AhatHeap; import com.android.ahat.heapdump.AhatInstance; import com.android.ahat.heapdump.AhatSnapshot; import com.android.ahat.heapdump.Diff; -import com.android.ahat.heapdump.FieldValue; import com.android.tools.perflib.heap.hprof.HprofClassDump; import com.android.tools.perflib.heap.hprof.HprofConstant; import com.android.tools.perflib.heap.hprof.HprofDumpRecord; @@ -129,35 +128,4 @@ public class DiffTest { // Diffing should not crash. Diff.snapshots(snapshot, snapshot); } - - @Test - public void diffFields() { - List a = new ArrayList(); - a.add(new FieldValue("n0", "t0", null)); - a.add(new FieldValue("n2", "t2", null)); - a.add(new FieldValue("n3", "t3", null)); - a.add(new FieldValue("n4", "t4", null)); - a.add(new FieldValue("n5", "t5", null)); - a.add(new FieldValue("n6", "t6", null)); - - List b = new ArrayList(); - b.add(new FieldValue("n0", "t0", null)); - b.add(new FieldValue("n1", "t1", null)); - b.add(new FieldValue("n2", "t2", null)); - b.add(new FieldValue("n3", "t3", null)); - b.add(new FieldValue("n5", "t5", null)); - b.add(new FieldValue("n6", "t6", null)); - b.add(new FieldValue("n7", "t7", null)); - - Diff.fields(a, b); - assertEquals(8, a.size()); - assertEquals(8, b.size()); - for (int i = 0; i < 8; i++) { - assertEquals(a.get(i), b.get(i).getBaseline()); - assertEquals(b.get(i), a.get(i).getBaseline()); - } - assertTrue(a.get(1).isPlaceHolder()); - assertTrue(a.get(7).isPlaceHolder()); - assertTrue(b.get(4).isPlaceHolder()); - } } -- cgit v1.2.3-59-g8ed1b