Package com.pugh.sockso.gui

Source Code of com.pugh.sockso.gui.MusicTreeTest

package com.pugh.sockso.gui;

import com.pugh.sockso.tests.SocksoTestCase;
import com.pugh.sockso.tests.TestDatabase;

import javax.swing.tree.TreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultMutableTreeNode;

public class MusicTreeTest extends SocksoTestCase {

    private MusicTree t;
    private DefaultTreeModel model;
    private DefaultMutableTreeNode root;

    @Override
    public void setUp() throws Exception {
        TestDatabase db = new TestDatabase();
        db.fixture( "musicTree" );
        t = new MusicTree( db );
        t.init();
        model = (DefaultTreeModel) t.getModel();
        root = (DefaultMutableTreeNode) model.getRoot();
    }

    public void testConstructorDoesNoWork() {
        new MusicTree( null );
    }

    public void testTreeCreatedWhenInitialised() {
        assertEquals( 2, root.getChildCount() );
    }

    public void testArtistNodesHaveDummyNodesWhenCreated() {
        assertEquals( 1, root.getChildAt(0).getChildCount() );
    }

    public void testAlbumsHaveDummyNodeWhenCreated() {
        TreeNode artist = root.getChildAt( 0 );
        t.expandNode( artist );
        assertEquals( 1, artist.getChildAt(0).getChildCount() );
        assertEquals( 1, artist.getChildAt(1).getChildCount() );
    }

    public void testAlbumsLoadedWhenArtistExpanded() {
        TreeNode artist = root.getChildAt( 0 );
        assertEquals( 1, artist.getChildCount() );
        t.expandNode( artist );
        assertEquals( 2, artist.getChildCount() );
    }

    public void testTracksLoadedWhenAlbumExpanded() {
        TreeNode artist = root.getChildAt( 0 );
        t.expandNode( artist );
        TreeNode album = artist.getChildAt( 0 );
        assertEquals( 1, album.getChildCount() );
        t.expandNode( album );
        assertEquals( 1, album.getChildCount() );
    }

    public void testArtistNodesNotExpandableIfTheyHaveNoAlbums() {
    }

    public void testAlbumNodesNotExpandableIfTheyHaveNoTracks() {
    }

    public void testRefreshingTreeAgainCreatesTreeWithJustArtists() {
    }

}
TOP

Related Classes of com.pugh.sockso.gui.MusicTreeTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.