2 * Copyright (c) 2004 JetBrains s.r.o. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * -Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * -Redistribution in binary form must reproduct the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the distribution.
15 * Neither the name of JetBrains or IntelliJ IDEA
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * This software is provided "AS IS," without a warranty of any kind. ALL
20 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
21 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
22 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. JETBRAINS AND ITS LICENSORS SHALL NOT
23 * BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT
24 * OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS
25 * DERIVATIVES. IN NO EVENT WILL JETBRAINS OR ITS LICENSORS BE LIABLE FOR ANY LOST
26 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
27 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
28 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
29 * IF JETBRAINS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 package com.intellij.dependencies;
34 import com.intellij.analysis.AnalysisScope;
35 import com.intellij.testFramework.IdeaTestUtil;
36 import com.intellij.openapi.util.Disposer;
37 import com.intellij.packageDependencies.DependenciesBuilder;
38 import com.intellij.packageDependencies.DependencyUISettings;
39 import com.intellij.packageDependencies.ForwardDependenciesBuilder;
40 import com.intellij.packageDependencies.ui.DependenciesPanel;
41 import com.intellij.packageDependencies.ui.PackagePatternProvider;
42 import com.intellij.psi.*;
43 import com.intellij.testFramework.TestSourceBasedTestCase;
44 import junit.framework.Assert;
48 public class DependenciesPanelTest extends TestSourceBasedTestCase{
49 public void testDependencies(){
50 DependenciesPanel dependenciesPanel = null;
52 final PsiDirectory psiDirectory = getPackageDirectory("com/package1");
53 Assert.assertNotNull(psiDirectory);
54 final PsiPackage psiPackage = JavaDirectoryService.getInstance().getPackage(psiDirectory);
55 Assert.assertNotNull(psiPackage);
56 final PsiClass[] classes = psiPackage.getClasses();
57 final PsiFile file = classes[0].getContainingFile();
58 final AnalysisScope scope = new AnalysisScope(file);
59 final DependenciesBuilder builder = new ForwardDependenciesBuilder(myProject, scope);
61 DependencyUISettings.getInstance().SCOPE_TYPE = PackagePatternProvider.PACKAGES;
62 dependenciesPanel = new DependenciesPanel(myProject, builder);
63 JTree leftTree = dependenciesPanel.getLeftTree();
64 IdeaTestUtil.assertTreeEqual(leftTree, "-Root\n" +
65 " Library Classes\n" +
66 " -Production Classes\n" +
67 " -" + myModule.getName() + "\n" +
70 " Test Classes\n", true);
72 JTree rightTree = dependenciesPanel.getRightTree();
73 IdeaTestUtil.assertTreeEqual(rightTree, "-Root\n" +
74 " Library Classes\n" +
75 " -Production Classes\n" +
76 " -" + myModule.getName() + "\n" +
79 " Test Classes\n", true);
82 if (dependenciesPanel != null) {
83 Disposer.dispose(dependenciesPanel);
88 protected String getTestPath() {
89 return "dependencies";