Migrate gallery app to use marionette By

Part of issue #1175

master -> Merge.
v1-train -> Merge.

Tests fail because of buG 901475, not related to this pull.