alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.test.debugger.Util;


import java.io.File;
import org.netbeans.jellytools.Bundle;
import org.netbeans.jellytools.ExplorerOperator;
import org.netbeans.jellytools.MainWindowOperator;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jellytools.NewWizardOperator;
import org.netbeans.jellytools.actions.Action;
import org.netbeans.jellytools.actions.MountLocalAction;
import org.netbeans.jellytools.nodes.JavaNode;
import org.netbeans.jellytools.nodes.Node;
import org.netbeans.jemmy.EventTool;
import org.netbeans.jemmy.JemmyProperties;
import org.netbeans.jemmy.operators.JFileChooserOperator;
import org.netbeans.jemmy.operators.JTreeOperator;
import org.netbeans.test.debugger.Util.DebuggerAPI;

import org.openide.filesystems.FileSystem;
import org.openide.filesystems.LocalFileSystem;
import org.openide.filesystems.Repository;

/**
 * Tests line breakpoint in anonymous inner class of anonymous inner class.
 *
 * @author Jan Stola
 */
public class GuiRunDebugger extends junit.framework.TestCase {
    
    public GuiRunDebugger(String name) {
        super(name);
    }    
    
    /**
     * Tests line breakpoint in anonymous inner class of anonymous inner class
     * using given debuggerType.
     *
     * @param debuggerType type of the debugger to be used.
     * @return value indicating whether the test was successful.
     */    
    public void testGuiRunDebugger() {        
//
            System.out.println("########  "+getName()+"  #######");
            mountSampledir();
            MainWindowOperator mainWindowOperator = MainWindowOperator.getDefault();
//            mainWindowOperator.switchToEditingWorkspace();
            ExplorerOperator explorerOperator = new ExplorerOperator();
            explorerOperator.selectPageFilesystems();
            Node repositoryRootNode = new ExplorerOperator().repositoryTab().getRootNode();
            JavaNode javaNode = new JavaNode(repositoryRootNode.tree(), System.getProperty("netbeans.user")+File.separator+"sampledir"+"|"+"examples"+"|"+"colorpicker"+"|"+"ColorPicker"); // NOI18N
            javaNode.select();
            String debugItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Debug"); // NOI18N
        //        String stepIntoItem = Bundle.getStringTrimmed("org.netbeans.core.actions.Bundle", "ExecutionView");
            String stepIntoItem = "Step Into";
            new Action(debugItem+"|"+stepIntoItem, null).perform();
            new EventTool().waitNoEvent(1000);
            mainWindowOperator = MainWindowOperator.getDefault();
//            mainWindowOperator.waitStatusText("Thread main stopped at examples.colorpicker.ColorPicker.main line 148.");
            new EventTool().waitNoEvent(10000);
            new Action(debugItem+"|"+"Finish", null).perform();
            try {
                JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout",5000);
                NbDialogOperator dialog = new NbDialogOperator("Finish Debugging Session");
                new EventTool().waitNoEvent(1000);
                dialog.ok();
            } catch (Exception exc) {                
                System.out.println("Dialog - Finish Debugging Session was not displayed.");
            }
            mainWindowOperator.waitStatusText("Debugger finished");
//            mainWindowOperator.switchToEditingWorkspace();
//
    }

    
    /** Mounts /sampledir through API
     * @return absolute path of mounted dir
     */
    private boolean mountSampledir() {
        new EventTool().waitNoEvent(1000);
        String userdir = System.getProperty("netbeans.user"); // NOI18N
        String mountPoint = userdir+File.separator+"sampledir"; // NOI18N
        mountPoint = mountPoint.replace('\\', '/');
        FileSystem fs = Repository.getDefault().findFileSystem(mountPoint);
        if (fs == null) {
            // invoke "File|Mount Filesystem" from main menu
            new MountLocalAction().perform();
            // wait for "New Wizard"
            NewWizardOperator newWizardOper = new NewWizardOperator();
            // select "Local Directory"
            JTreeOperator tree = new JTreeOperator(newWizardOper);
            String localDirLabel = Bundle.getString("org.netbeans.core.Bundle", "Templates/Mount/org-netbeans-core-ExLocalFileSystem.settings"); // NOI18N
            new Node(tree, localDirLabel).select();
            newWizardOper.next();
            // select sampledir in file chooser
            File file = new File(mountPoint);
            new JFileChooserOperator().setSelectedFile(file);
            // finish wizard
            newWizardOper.finish();
        }
        return true;
    }
    
}

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.