質問

    @Before public void setUp() {
        Robot robot = BasicRobot.robotWithCurrentAwtHierarchy();
        ApplicationLauncher.application("myApp").start(); 

        Pause.pause(5, TimeUnit.SECONDS); 
        frame = WindowFinder.findFrame("frame0").using(robot);

        JTableFixture table = frame.table(new GenericTypeMatcher<JTable>(JTable.class) {
             @Override protected boolean isMatching(JTable table) {
                return (table instanceof myTreeTable); 
             }  
        });
    }
.

このコードはうまく機能します。5秒の一時停止を削除した場合、テーブルはそれがアプリをロードするために数秒かかるために見つかりません。

私はそれをやることのよりきれいな方法があるかどうか知りたいのです。ApplicationLauncherの後にRobot.Waitforidle()で試しました(EDTが空の場合はすべてがロードされていると思います)、それは動作しません。

私は一時停止がいつ停止するイベントとしていくつかの条件を使うことができますが、Javadocと公式文書が貧弱であることを理解していません。

  • pause.pause(waitforcomponentToshowCondition.untilissing(frame.component()):コンポーネントが必要です。ラッパーフレームを渡すとうまくいきません。そして私はテーブルを渡すことができませんので、それは正確に私が待っているのを待っています。
  • 私はおそらくComponentFoundSconditionと仕事をするべきですが、私はそれを手に入れてはいけません!私は疲れています:

           ComponentMatcher matcher = new GenericTypeMatcher<JTable>(JTable.class) {
               @Override protected boolean isMatching(JTable table) {
                 return (table instanceof myTreeTable); 
               }  
           };
    
           Pause.pause(new ComponentFoundCondition("DebugMsg", frame.robot.finder(), matcher)); 
    

    助け?

役に立ちましたか?

解決

componentFinder を探すコンポーネント。たとえば、質問のマッチャーに基づく:

final ComponentMatcher matcher = new TypeMatcher(myTreeTable.class);

Pause.pause(new Condition("Waiting for myTreeTable") {
    @Override
    public boolean test() {
        Collection<Component> list = 
                window.robot.finder().findAll(window.target, matcher);
        return list.size() > 0;
    }
 }, 5000); 
.

これは名前によるルックアップ付きの代替手段です:

final ComponentMatcher nameMatcher = new ComponentMatcher(){
    @Override
    public boolean matches(Component c) {
        return "ComponentName".equals(c.getName()) && c.isShowing();
    }
};

Pause.pause(new Condition("Waiting") {
    @Override
    public boolean test() {
        Collection<Component> list = 
                window.robot.finder().findAll(window.target, nameMatcher);
        return list.size() > 0;
    }
 }, 5000);
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top