diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksDecorationExposer.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksDecorationExposer.java index 03c77b44b..b81756dbd 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksDecorationExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksDecorationExposer.java @@ -52,7 +52,7 @@ public class GtasksDecorationExposer implements TaskDecorationExposer { RemoteViews decoration = new RemoteViews(ContextManager.getContext().getPackageName(), R.layout.gtasks_decoration); - decoration.setInt(R.id.indent, "setWidth", indentation * 20); //$NON-NLS-1$ + decoration.setInt(R.id.indent, "setMinWidth", indentation * 20); //$NON-NLS-1$ return new TaskDecoration(decoration, TaskDecoration.POSITION_LEFT, 0); } diff --git a/astrid/rmilk-src/org/weloveastrid/rmilk/MilkDetailExposer.java b/astrid/rmilk-src/org/weloveastrid/rmilk/MilkDetailExposer.java index 8a291d788..773fbeb0a 100644 --- a/astrid/rmilk-src/org/weloveastrid/rmilk/MilkDetailExposer.java +++ b/astrid/rmilk-src/org/weloveastrid/rmilk/MilkDetailExposer.java @@ -36,6 +36,10 @@ public class MilkDetailExposer extends BroadcastReceiver { @Autowired private MilkMetadataService milkMetadataService; @Autowired private MilkListService milkListService; + static { + MilkDependencyInjector.initialize(); + } + @Override public void onReceive(Context context, Intent intent) { ContextManager.setContext(context); diff --git a/astrid/rmilk-src/org/weloveastrid/rmilk/MilkFilterExposer.java b/astrid/rmilk-src/org/weloveastrid/rmilk/MilkFilterExposer.java index ee52f7461..598213e27 100644 --- a/astrid/rmilk-src/org/weloveastrid/rmilk/MilkFilterExposer.java +++ b/astrid/rmilk-src/org/weloveastrid/rmilk/MilkFilterExposer.java @@ -40,6 +40,10 @@ public class MilkFilterExposer extends BroadcastReceiver { @Autowired private MilkListService milkListService; + static { + MilkDependencyInjector.initialize(); + } + private Filter filterFromList(Context context, StoreObject list) { String listName = list.getValue(MilkListFields.NAME); String title = context.getString(R.string.rmilk_FEx_list_title, diff --git a/astrid/rmilk-src/org/weloveastrid/rmilk/sync/MilkSyncProvider.java b/astrid/rmilk-src/org/weloveastrid/rmilk/sync/MilkSyncProvider.java index 8e7487e61..9cbdefd1c 100644 --- a/astrid/rmilk-src/org/weloveastrid/rmilk/sync/MilkSyncProvider.java +++ b/astrid/rmilk-src/org/weloveastrid/rmilk/sync/MilkSyncProvider.java @@ -11,6 +11,7 @@ import java.util.HashSet; import java.util.List; import org.weloveastrid.rmilk.MilkBackgroundService; +import org.weloveastrid.rmilk.MilkDependencyInjector; import org.weloveastrid.rmilk.MilkLoginActivity; import org.weloveastrid.rmilk.MilkPreferences; import org.weloveastrid.rmilk.MilkUtilities; @@ -64,6 +65,10 @@ public class MilkSyncProvider extends SyncProvider { @Autowired private MilkMetadataService milkMetadataService; @Autowired private MilkListService milkListService; + static { + MilkDependencyInjector.initialize(); + } + // ---------------------------------------------------------------------- // ------------------------------------------------------- public methods // ---------------------------------------------------------------------- diff --git a/tests/src/com/todoroo/andlib/test/TodorooTestCaseWithInjector.java b/tests/src/com/todoroo/andlib/test/TodorooTestCaseWithInjector.java index 5142ad864..1b7ce6cfa 100644 --- a/tests/src/com/todoroo/andlib/test/TodorooTestCaseWithInjector.java +++ b/tests/src/com/todoroo/andlib/test/TodorooTestCaseWithInjector.java @@ -1,7 +1,5 @@ package com.todoroo.andlib.test; -import android.test.AndroidTestCase; - import com.todoroo.andlib.service.TestDependencyInjector; /** @@ -10,7 +8,7 @@ import com.todoroo.andlib.service.TestDependencyInjector; * @author Tim Su * */ -abstract public class TodorooTestCaseWithInjector extends AndroidTestCase { +abstract public class TodorooTestCaseWithInjector extends TodorooTestCase { protected TestDependencyInjector testInjector; diff --git a/tests/src/com/todoroo/astrid/gtasks/GtasksDecorationExposerTest.java b/tests/src/com/todoroo/astrid/gtasks/GtasksDecorationExposerTest.java index 0fd334687..dcf73c608 100644 --- a/tests/src/com/todoroo/astrid/gtasks/GtasksDecorationExposerTest.java +++ b/tests/src/com/todoroo/astrid/gtasks/GtasksDecorationExposerTest.java @@ -1,7 +1,6 @@ package com.todoroo.astrid.gtasks; import android.view.View; -import android.widget.FrameLayout; import android.widget.RemoteViews; import com.todoroo.astrid.api.Filter; @@ -19,7 +18,7 @@ public class GtasksDecorationExposerTest extends DatabaseTestCase { private TaskDecoration result; public void testExposeNotLoggedIn() { - givenLoggedInStatus(true); + givenLoggedInStatus(false); whenRequestingDecoration(gtasksFilter(), indentedTask(1)); @@ -27,7 +26,7 @@ public class GtasksDecorationExposerTest extends DatabaseTestCase { } public void testExposeLoggedInButNormalFilter() { - givenLoggedInStatus(false); + givenLoggedInStatus(true); whenRequestingDecoration(nonGtasksFilter(), indentedTask(1)); @@ -42,7 +41,7 @@ public class GtasksDecorationExposerTest extends DatabaseTestCase { thenExpectDecoration(1); } - public void testExposeIndentationWithNormalTask() { + public void testExposeIndentationWithTopLevelTask() { givenLoggedInStatus(true); whenRequestingDecoration(gtasksFilter(), nonIndentedTask()); @@ -63,13 +62,14 @@ public class GtasksDecorationExposerTest extends DatabaseTestCase { private void thenExpectWiderThan(Task otherTask) { assertNotNull(result); RemoteViews view = result.decoration; - FrameLayout parent = new FrameLayout(getContext()); - View inflated = view.apply(getContext(), parent); - int width = inflated.getWidth(); + View inflated = view.apply(getContext(), null); + inflated.measure(100, 100); + int width = inflated.getMeasuredWidth(); result = new GtasksDecorationExposer().expose(gtasksFilter(), otherTask); - View otherInflated = result.decoration.apply(getContext(), parent); - int otherWidth = otherInflated.getWidth(); + View otherInflated = result.decoration.apply(getContext(), null); + otherInflated.measure(100, 100); + int otherWidth = otherInflated.getMeasuredWidth(); assertTrue(width + " > " + otherWidth, width > otherWidth); } @@ -84,9 +84,9 @@ public class GtasksDecorationExposerTest extends DatabaseTestCase { private void thenExpectDecoration(int minWidth) { assertNotNull(result); RemoteViews view = result.decoration; - FrameLayout parent = new FrameLayout(getContext()); - View inflated = view.apply(getContext(), parent); - assertTrue("actual: " + inflated.getWidth(), inflated.getWidth() > minWidth); + View inflated = view.apply(getContext(), null); + inflated.measure(100, 100); + assertTrue("actual: " + inflated.getMeasuredWidth(), inflated.getMeasuredWidth() > minWidth); } private Filter gtasksFilter() { @@ -101,13 +101,13 @@ public class GtasksDecorationExposerTest extends DatabaseTestCase { PluginServices.getTaskService().save(task); Metadata metadata = GtasksMetadata.createEmptyMetadata(); metadata.setValue(GtasksMetadata.INDENTATION, indentation); + metadata.setValue(Metadata.TASK, task.getId()); PluginServices.getMetadataService().save(metadata); return task; } private Filter nonGtasksFilter() { return CoreFilterExposer.buildInboxFilter(getContext().getResources()); - } @Override diff --git a/tests/src/com/todoroo/astrid/test/DatabaseTestCase.java b/tests/src/com/todoroo/astrid/test/DatabaseTestCase.java index f3d801809..b8cd51cf4 100644 --- a/tests/src/com/todoroo/astrid/test/DatabaseTestCase.java +++ b/tests/src/com/todoroo/astrid/test/DatabaseTestCase.java @@ -15,12 +15,12 @@ import com.todoroo.astrid.service.AstridDependencyInjector; */ public class DatabaseTestCase extends TodorooTestCaseWithInjector { - public static Database database = new TestDatabase(); - static { AstridDependencyInjector.initialize(); } + public static Database database = new TestDatabase(); + @Override protected void addInjectables() { testInjector.addInjectable("database", database);