Changeset 31482 in osm for applications/editors


Ignore:
Timestamp:
2015-08-11T15:43:11+02:00 (9 years ago)
Author:
nokutu
Message:

Fixed bug related to progress numbers during upload and added unit test for PluginState class

Location:
applications/editors/josm/plugins/mapillary
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/build.xml

    r31480 r31482  
    55    <property name="plugin.main.version" value="8433"/>
    66    <property name="plugin.canloadatruntime" value="true"/>
    7     <property name="plugin.version" value="0.9.1"/>
     7    <property name="plugin.version" value="0.9.2"/>
    88    <property name="plugin.author" value="nokutu &lt;nokutu@openmailbox.org&gt;"/>
    99    <property name="plugin.class" value="org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin"/>
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java

    r31475 r31482  
    176176      }
    177177      this.ex.shutdown();
    178       PluginState.finishUpload();
    179178    }
    180179  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/PluginState.java

    r31474 r31482  
    1818  private static int runningDownloads = 0;
    1919  /** Images that have to be uploaded. */
    20   public static int imagesToUpload = 0;
     20  protected static int imagesToUpload = 0;
    2121  /** Images that have been uploaded. */
    2222  public static int imagesUploaded = 0;
     
    3333   */
    3434  public static void finishDownload() {
     35    if (runningDownloads == 0)
     36      throw new IllegalStateException(
     37          "The amount of running downlaods is less or equals to 0");
    3538    runningDownloads--;
    3639  }
     
    4346  public static boolean isDownloading() {
    4447    return runningDownloads > 0;
    45   }
    46 
    47   /**
    48    * Called when an upload is finished.
    49    */
    50   public static void finishUpload() {
    51     if (imagesUploaded >= imagesToUpload) {
    52       imagesUploaded = 0;
    53       imagesToUpload = 0;
    54     }
    5548  }
    5649
     
    7164   */
    7265  public static void imagesToUpload(int amount) {
     66    if (imagesToUpload <= imagesUploaded) {
     67      imagesToUpload = 0;
     68      imagesUploaded = 0;
     69    }
    7370    imagesToUpload += amount;
    7471  }
     
    8077    imagesUploaded++;
    8178    if (imagesToUpload == imagesUploaded) {
    82       finishedUploadDialog();
     79      if (Main.main != null)
     80        finishedUploadDialog();
    8381    }
    8482  }
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryRecordTest.java

    r31476 r31482  
    4141  @Test
    4242  public void commandTest() {
    43     MapillaryCommand cmd1 = new CommandMoveImage(
     43    MapillaryCommand cmd12 = new CommandMoveImage(
    4444        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
    4545        0.1, 0.1);
    46     MapillaryCommand cmd2 = new CommandMoveImage(
     46    MapillaryCommand cmd23 = new CommandMoveImage(
    4747        Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }),
    4848        0.1, 0.1);
    49     MapillaryCommand cmd3 = new CommandMoveImage(
     49    MapillaryCommand cmd13 = new CommandMoveImage(
    5050        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img3 }),
     51        0.1, 0.1);
     52    MapillaryCommand cmd1 = new CommandMoveImage(
     53        Arrays.asList(new MapillaryAbstractImage[] { this.img1 }),
    5154        0.1, 0.1);
    5255    MapillaryCommand cmd31 = new CommandMoveImage(
    5356        Arrays.asList(new MapillaryAbstractImage[] { this.img3, this.img1 }),
    5457        0.2, 0.2);
    55     this.record.addCommand(cmd1);
    56     this.record.addCommand(cmd2);
     58    this.record.addCommand(cmd12);
     59    this.record.addCommand(cmd23);
    5760
    5861    assertEquals(1, this.record.position);
     
    6467    assertEquals(2, this.record.commandList.size());
    6568
    66     this.record.addCommand(cmd3);
     69    this.record.addCommand(cmd1);
    6770
    6871    assertEquals(1, this.record.position);
    69     assertEquals(2, this.record.commandList.size());
     72
     73    this.record.addCommand(cmd13);
     74
     75    assertEquals(2, this.record.position);
     76    assertEquals(3, this.record.commandList.size());
    7077
    7178    this.record.undo();
    7279    this.record.redo();
    7380
    74     assertEquals(1, this.record.position);
    75     assertEquals(2, this.record.commandList.size());
     81    assertEquals(2, this.record.position);
     82    assertEquals(3, this.record.commandList.size());
    7683
    7784    this.record.addCommand(cmd31);
    7885
    79     assertEquals(1, this.record.position);
    80     assertEquals(2, this.record.commandList.size());
     86    assertEquals(2, this.record.position);
     87    assertEquals(3, this.record.commandList.size());
     88
     89    this.record.addCommand(cmd1);
     90
     91    assertEquals(3, this.record.position);
     92    assertEquals(4, this.record.commandList.size());
    8193  }
    8294
Note: See TracChangeset for help on using the changeset viewer.