Package com.google.gdt.eclipse.designer.mobile.device

Source Code of com.google.gdt.eclipse.designer.mobile.device.DeviceSelectionSupportXmlGefTest

/*******************************************************************************
* Copyright 2011 Google Inc. All Rights Reserved.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.google.gdt.eclipse.designer.mobile.device;

import com.google.gdt.eclipse.designer.mobile.device.model.DeviceInfo;
import com.google.gdt.eclipse.designer.model.widgets.IUIObjectInfo;
import com.google.gdt.eclipse.designer.uibinder.gef.UiBinderGefTest;
import com.google.gdt.eclipse.designer.uibinder.model.widgets.ComplexPanelInfo;

import org.eclipse.wb.draw2d.Figure;
import org.eclipse.wb.draw2d.geometry.Rectangle;
import org.eclipse.wb.gef.graphical.GraphicalEditPart;

/**
* Test for {@link DeviceSelectionSupport} in GEF, using UiBinder.
*
* @author scheglov_ke
*/
public class DeviceSelectionSupportXmlGefTest extends UiBinderGefTest {
  ////////////////////////////////////////////////////////////////////////////
  //
  // Exit zone :-) XXX
  //
  ////////////////////////////////////////////////////////////////////////////
  public void _test_exit() throws Exception {
    System.exit(0);
  }

  ////////////////////////////////////////////////////////////////////////////
  //
  // Tests
  //
  ////////////////////////////////////////////////////////////////////////////
  /**
   * Use {@link DeviceSelectionSupport#setDevice(IUIObjectInfo, DeviceInfo)} directly.
   */
  public void test_setDevice() throws Exception {
    ComplexPanelInfo originalPanel;
    {
      originalPanel =
          openEditor(
              "// filler filler filler filler filler",
              "// filler filler filler filler filler",
              "<ui:UiBinder>",
              "  <g:FlowPanel/>",
              "</ui:UiBinder>");
      GraphicalEditPart panelEditPart = canvas.getEditPart(originalPanel);
      Figure panelFigure = panelEditPart.getFigure();
      // no device yet
      assertEquals(new Rectangle(20, 20, 450, 300), panelFigure.getBounds());
      // set device
      DeviceSelectionSupport.setDevice(originalPanel, DeviceManager.getDevice("generic.qvga"));
      assertEquals(new Rectangle(25, 25, 240, 320), panelFigure.getBounds());
    }
    // parse again
    {
      openSourcePage();
      m_lastContext.getDocument().replace(0, 0, " ");
      openDesignPage();
      fetchContentFields();
    }
    // ...still has device
    {
      assertNotSame(originalPanel, m_contentObject);
      GraphicalEditPart panelEditPart = canvas.getEditPart(m_contentObject);
      Figure panelFigure = panelEditPart.getFigure();
      assertEquals(new Rectangle(25, 25, 240, 320), panelFigure.getBounds());
    }
  }
}
TOP

Related Classes of com.google.gdt.eclipse.designer.mobile.device.DeviceSelectionSupportXmlGefTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.