Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9f46331def4d441f0b6546394993efee5c57efc4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Copyright (c) 2010-2012, 2015 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Martin Fluegge - initial API and implementation
 */
package org.eclipse.emf.cdo.tests.ui;

import org.eclipse.emf.cdo.internal.ui.views.CDOSessionsView;

import org.eclipse.swt.SWT;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.keyboard.Keyboard;
import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCCombo;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.ui.IViewPart;

import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
 * @author Martin Fluegge
 */
@RunWith(SWTBotJunit4ClassRunner.class)
public class CDOSessionsViewTest extends AbstractCDOUITest<SWTWorkbenchBot>
{
  @Override
  @After
  public void tearDown() throws Exception
  {
    closeAllEditors();
    super.tearDown();
  }

  @Test
  public void testOpenSessionsView() throws Exception
  {
    getBot().menu("Window").menu("Show View").menu("Other...").click();

    SWTBotShell shell = getBot().shell("Show View");
    shell.activate();
    getBot().tree().expandNode("CDO").select("CDO Sessions");
    getBot().button("OK").click();

    SWTBotView activeView = getBot().activeView();
    assertEquals("CDO Sessions", activeView.getViewReference().getTitle());
    IViewPart view = activeView.getViewReference().getView(false);
    assertInstanceOf(CDOSessionsView.class, view);

    // activeView.toolbarButton(OpenSessionDialog.TITLE).click();
    activeView.toolbarButton(org.eclipse.emf.cdo.internal.ui.messages.Messages.getString("OpenSessionAction.0"))
        .click();

    SWTBotShell openSessionDialog = getBot().shell("Open Session");
    openSessionDialog.activate();
    SWTBotCCombo ccomboBox = getBot().ccomboBox(0);
    ccomboBox.setFocus();

    Keyboard keyboard = KeyboardFactory.getDefaultKeyboard(ccomboBox.widget, null);
    keyboard.typeText("tcp");
    keyboard.pressShortcut(SWT.SHIFT, '.');
    keyboard.pressShortcut(SWT.SHIFT, '7');
    keyboard.pressShortcut(SWT.SHIFT, '7');
    keyboard.typeText("localhost");

    SWTBotCCombo repositoryNameCcomboBox = getBot().ccomboBox(1);
    repositoryNameCcomboBox.setFocus();

    typeTextToFocusedWidget("repo1", getBot(), false);

    getBot().button("OK").click();

    activeView.setFocus();
    SWTBotTree tree = getBot().tree(0);
    sleep(3000);
    assertEquals(1, tree.getAllItems().length);
    assertEquals("Session repo1 [2]", tree.getAllItems()[0].getText());
  }
}

Back to the top