⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 collectioncomponentmatcherstest.java

📁 基于Junit的 功能和单元测试的的测试工具。只支持Swing.
💻 JAVA
字号:
package org.uispec4j.finder;

import org.uispec4j.TestUtils;

import javax.swing.*;
import java.awt.*;

public class CollectionComponentMatchersTest extends PanelComponentFinderTestCase {
  private Component component1;
  private Component component2;
  private Component component3;
  private Component component4;

  protected void setUp() throws Exception {
    super.setUp();
    component1 = addComponent(JButton.class, "some text");
    component2 = addComponent(JButton.class, "other text");
    component3 = addComponent(JButton.class, "nothing");
    component4 = addComponent(JTextField.class, "last text");
  }

  public void testIntersectionMatcher() throws Exception {
    ComponentMatcher matcher = ComponentMatchers.intersection(
      new ComponentMatcher[]{
        ComponentMatchers.displayedNameSubstring("text"),
        ComponentMatchers.fromClass(JButton.class)
      });

    TestUtils.assertSwingComponentsEquals(new Component[]{component1, component2},
                                          panel.getSwingComponents(matcher));
  }

  public void testUnionComponentMatcher() throws Exception {
    ComponentMatcher matcher = ComponentMatchers.union(
      new ComponentMatcher[]{
        ComponentMatchers.displayedNameSubstring("text"),
        ComponentMatchers.fromClass(JButton.class)
      });

    TestUtils.assertSwingComponentsEquals(new Component[]{component1, component2, component3, component4},
                                          panel.getSwingComponents(matcher));
  }

  public void testNegatedComponentMatcher() throws Exception {
    ComponentMatcher matcher = ComponentMatchers.not(ComponentMatchers.displayedNameSubstring("text"));
    TestUtils.assertSwingComponentsEquals(new Component[]{component3},
                                          panel.getSwingComponents(matcher));
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -