#12983 closed enhancement (fixed)
use layer manager in Command
Reported by: | anonymous | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 16.06 |
Component: | Core | Version: | latest |
Keywords: | gsoc-core | Cc: | michael2402 |
Description (last modified by )
The Command class should get the active layer from the layer manager. otherwise it does not seem possible to use the command in a test with JOSMTestRules, because "Main.main" is null.
package org.openstreetmap.josm.command: /** * Creates a new command in the context of the current edit layer, if any */ public Command() { this.layer = Main.main == null ? null : Main.main.getEditLayer(); }
Attachments (0)
Change History (7)
comment:1 by , 8 years ago
comment:2 by , 8 years ago
new class in unit tests to speed up/replace JOSMFixtures (part of Michael's work)
comment:3 by , 8 years ago
Cc: | added |
---|---|
Keywords: | gsoc-core added |
comment:4 by , 8 years ago
JOSMTestRules sets up the test environment more fine-graned than JOSMFixture does.
The main Idea is that you do not need a whole JOSM instance to get a simple unit test running. This is only possible if we reduce dependencies, e.g. that Command depends on Main.
I would like to deprecate all Main.*Layer*() methods except for getLayerManager() and replace them in the existing source.
You can replace this line:
this.layer = Main.main == null ? null : Main.main.getEditLayer();
With this one:
this.layer = Main.getLayerManager().getEditLayer();
The MainLayerManager will handle the case of an empty layer list automatically.
comment:6 by , 8 years ago
Milestone: | → 16.06 |
---|---|
Type: | defect → enhancement |
comment:7 by , 8 years ago
Description: | modified (diff) |
---|
Could you give a bit more context, what is JOSMTestRules?