/sigmah/src/test/java/org/sigmah/client/page/entry/editor/SiteFormTest.java

http://sigma-h.googlecode.com/ · Java · 86 lines · 39 code · 26 blank · 21 comment · 0 complexity · 65df264b25ca51cdc635196abc5b95ce MD5 · raw file

  1. /*
  2. * All Sigmah code is released under the GNU General Public License v3
  3. * See COPYRIGHT.txt and LICENSE.txt.
  4. */
  5. package org.sigmah.client.page.entry.editor;
  6. import org.junit.Assert;
  7. import org.junit.Ignore;
  8. import org.junit.Test;
  9. import org.sigmah.client.mock.DispatcherStub;
  10. import org.sigmah.client.mock.DummyData;
  11. import org.sigmah.client.mock.MockEventBus;
  12. import org.sigmah.client.page.common.toolbar.UIActions;
  13. import org.sigmah.client.page.entry.editor.mock.MockSiteForm;
  14. import org.sigmah.shared.dto.SchemaDTO;
  15. import com.google.gwt.junit.GWTMockUtilities;
  16. /**
  17. * @author Alex Bertram (akbertram@gmail.com)
  18. */
  19. public class SiteFormTest {
  20. @Ignore("needs to be converted to GWT test")
  21. @Test
  22. public void testAdminInit() {
  23. GWTMockUtilities.disarm();
  24. // Test data
  25. SchemaDTO schema = DummyData.PEAR();
  26. // Collaborator: EventBus
  27. MockEventBus eventBus = new MockEventBus();
  28. // Collaborator: Command Service
  29. DispatcherStub service = new DispatcherStub();
  30. // Collaborator: View
  31. MockSiteForm form = new MockSiteForm();
  32. // CLASS UNDER TEST
  33. SiteForm presenter = new SiteForm(service, schema.getActivityById(91));
  34. presenter.setSite(DummyData.PEAR_Sites().get(4));
  35. // Verify that the admin field set is intialzed
  36. Assert.assertEquals("province is set", "Nord Kivu", form.adminFieldSet.getValue(1).getName());
  37. // Verify the save button is disabled
  38. Assert.assertFalse("save action is disabled", form.isEnabled(UIActions.save));
  39. // Verify that a change to the admin field set enables the save button
  40. form.adminFieldSet.setValueAndFire(1, DummyData.SudKivu);
  41. Assert.assertTrue("save button is now enabled", form.isEnabled(UIActions.save));
  42. }
  43. @Ignore("needs to be converted to GWT test")
  44. @Test
  45. public void testMapBoundsSetOnInit() {
  46. // Test data
  47. SchemaDTO schema = DummyData.PEAR();
  48. // Collaborator: EventBus
  49. MockEventBus eventBus = new MockEventBus();
  50. // Collaborator: Command Service
  51. DispatcherStub service = new DispatcherStub();
  52. // Collaborator: View
  53. MockSiteForm form = new MockSiteForm();
  54. // CLASS UNDER TEST
  55. SiteFormPresenter presenter = new SiteFormPresenter(eventBus,service, schema.getActivityById(91), form);
  56. presenter.setSite(DummyData.PEAR_Sites().get(4));
  57. // Verify that the map view has been centered on the admin bounds
  58. Assert.assertTrue(form.mapView.getMapView().contains(DummyData.Beni.getBounds()));
  59. }
  60. }