package com.explodingpixels.macwidgets; import com.explodingpixels.macwidgets.DSourceListITunes; import com.explodingpixels.macwidgets.SourceList; import com.explodingpixels.macwidgets.SourceListCategory; import com.explodingpixels.macwidgets.SourceListDarkColorScheme; import com.explodingpixels.macwidgets.SourceListItem; import com.explodingpixels.macwidgets.SourceListModel; import com.explodingpixels.widgets.WindowUtils; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.SwingUtilities; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.awt.BorderLayout; public class DSourceListIMovieTest { public static SourceList createSourceList() { Icon eventIcon = new ImageIcon(DSourceListITunes.class.getResource("/com/explodingpixels/macwidgets/icons/Event.png")); Icon projectIcon = new ImageIcon(DSourceListITunes.class.getResource("/com/explodingpixels/macwidgets/icons/Project.png")); final SourceListModel model = new SourceListModel(); SourceListCategory projectsCategory = new SourceListCategory("Projects"); SourceListCategory eventsCategory = new SourceListCategory("Categories"); model.addCategory(projectsCategory); model.addCategory(eventsCategory); SourceListItem projectTwo = new SourceListItem("Project two", projectIcon); projectTwo.setCounterValue(3); model.addItemToCategory(new SourceListItem("Project one", projectIcon), projectsCategory); model.addItemToCategory(projectTwo, projectsCategory); model.addItemToCategory(new SourceListItem("Project three", projectIcon), projectsCategory); model.addItemToCategory(new SourceListItem("Project four", projectIcon), projectsCategory); model.addItemToCategory(new SourceListItem("Event A", eventIcon), eventsCategory); model.addItemToCategory(new SourceListItem("Event B", eventIcon), eventsCategory); model.addItemToCategory(new SourceListItem("Event C", eventIcon), eventsCategory); SourceList sourceList = new SourceList(model); sourceList.setColorScheme(new SourceListDarkColorScheme()); return sourceList; } @Test public void doTest() throws Exception { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(); WindowUtils.createAndInstallRepaintWindowFocusListener(frame); frame.add(createSourceList().getComponent(), BorderLayout.CENTER); frame.setSize(225, 250); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); } }); } @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } }