void () { TestAttachGroup group1 = new TestAttachGroup("group1", 1); TestAttachGroup group2 = new TestAttachGroup("group2", 2); List<XAttachDebugger> debuggers1 = createDebuggers("gdb1", "lldb1"); List<XAttachDebugger> debuggers2 = createDebuggers("gdb2", "lldb2"); List<AttachToProcessItem> originalItems = fixtureCollectAttachItems(new ProcessInfo[]{ new ProcessInfo(1, "command line 1", "exec1", "args1"), new ProcessInfo(2, "command line 2", "exec2", "args2")}, new TestDebuggerProvider(1, group1, debuggers1), new TestDebuggerProvider(2, group2, debuggers2)); // one item in history addToRecent(getProject(), originalItems.get(0)); assertItems(""" ----Recent---- 10 exec10: gdb1 gdb1 lldb1 ----group1---- 10 exec10: gdb1 gdb1 lldb1 ----group2---- 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2)); // several items in history addToRecent(getProject(), originalItems.get(1)); assertItems(""" ----Recent---- 20 exec20: gdb2 gdb2 lldb2 10 exec10: gdb1 gdb1 lldb1 ----group1---- 10 exec10: gdb1 gdb1 lldb1 ----group2---- 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2)); // put most recent item on top addToRecent(getProject(), originalItems.get(0)); assertItems(""" ----Recent---- 10 exec10: gdb1 gdb1 lldb1 20 exec20: gdb2 gdb2 lldb2 ----group1---- 10 exec10: gdb1 gdb1 lldb1 ----group2---- 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2)); // put debugger used in history item on top addToRecent(getProject(), originalItems.get(0).getSubItems().get(1)); addToRecent(getProject(), originalItems.get(1).getSubItems().get(1)); assertItems(""" ----Recent---- 20 exec20: lldb2 gdb2 lldb2 10 exec10: lldb1 gdb1 lldb1 ----group1---- 10 exec10: gdb1 gdb1 lldb1 ----group2---- 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2)); // filter unavailable history items assertItems(""" ----Recent---- 20 exec20: lldb2 gdb2 lldb2 ----group1---- 10 exec10: gdb1 gdb1 lldb1 ----group2---- 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 10", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2)); assertItems(""" ----group1---- 10 exec10: gdb1 gdb1 lldb1 ----group2---- 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 10", "exec10", "args10"), new ProcessInfo(20, "command line 20", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2)); // history items available again: assertItems(""" ----Recent---- 20 exec20: lldb2 gdb2 lldb2 10 exec10: lldb1 gdb1 lldb1 ----group1---- 10 exec10: gdb1 gdb1 lldb1 ----group2---- 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2)); // filter items from history by suitable group assertItems(""" ----Recent---- 10 exec10: lldb1 gdb1 lldb1 ----group1---- 10 exec10: gdb1 gdb1 lldb1 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group1, debuggers2)); assertItems(""" ----Recent---- 20 exec20: lldb2 gdb2 lldb2 ----group2---- 10 exec10: gdb1 gdb1 lldb1 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group2, debuggers1), new TestDebuggerProvider(20, group2, debuggers2)); // filter by group equality, not by name assertItems(""" ----group1---- 10 exec10: gdb1 gdb1 lldb1 ----group2---- 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, new TestAttachGroup(group1.getGroupName(), group1.getOrder()), debuggers1), new TestDebuggerProvider(20, new TestAttachGroup(group2.getGroupName(), group2.getOrder()), debuggers2)); // filter items from history by available debugger assertItems(""" ----Recent---- 10 exec10: lldb1 gdb1 lldb1 ----group1---- 10 exec10: gdb1 gdb1 lldb1 ----group2---- 20 exec20: gdb1 gdb1 lldb1 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers1)); // filter debuggers by name, not by equality assertItems(""" ----Recent---- 20 exec20: lldb2 gdb2 lldb2 10 exec10: lldb1 gdb1 lldb1 ----group1---- 10 exec10: gdb1 gdb1 lldb1 ----group2---- 20 exec20: gdb2 gdb2 lldb2 """, new ProcessInfo[]{ new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, createDebuggers("gdb1", "lldb1")), new TestDebuggerProvider(20, group2, createDebuggers("gdb2", "lldb2"))); }