Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #23072 from crdlc/bug-1055324
Browse files Browse the repository at this point in the history
Bug 1055324 - [B2G][OTA][1.3 -> 2.0] E.Me apps on the homescreen do not ...
  • Loading branch information
Cristian Rodriguez authored and rvandermeulen committed Aug 21, 2014
1 parent c6836ff commit ed25745
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apps/homescreen/js/grid_components.js
Expand Up @@ -201,9 +201,9 @@ Collection.prototype = {
});
} else {
// If E.me has not been initialzed for the smart collections,
// we early-return. We let the default smart collections be populated
// we skip migration. We let the default smart collections be populated
// for the vertical homescreen instead.
return;
descriptor.skipMigration = true;
}
var categoryId = descriptor.categoryId || this.providerId;
var id = parseInt(categoryId);
Expand Down
8 changes: 6 additions & 2 deletions apps/homescreen/js/migrator.js
Expand Up @@ -91,8 +91,12 @@
GridItemsFactory.create(icon).getDescriptor(function(descriptor) {
icon.record.id = descriptor.type === types.COLLECTION ?
descriptor.id : descriptor.url;
console.debug('Migrated to datastore', JSON.stringify(descriptor));
database.add(descriptor).then(onItemMigrated, onItemMigrated);
if (descriptor.skipMigration) {
onItemMigrated();
} else {
console.debug('Migrated to datastore', JSON.stringify(descriptor));
database.add(descriptor).then(onItemMigrated, onItemMigrated);
}
});
}.bind(this));

Expand Down
41 changes: 41 additions & 0 deletions apps/homescreen/test/unit/migrator_test.js
Expand Up @@ -528,4 +528,45 @@ suite('migrator.js >', function() {
startMigration();
});

test('Skip CollectionsDatabase when E.me has not been initialzed',
function(done) {
var page = {
'index': 0,
'icons': [ createIcon('collection', {
type: GridItemsFactory.TYPE.COLLECTION,
provider_id: 234
}),
createIcon('app')
]
};

port.postMessage = function(msg) {
assert.equal(msg, 'Done');

assert.isFalse(bdAddStub.called);
assert.equal(bookmarks.length, 0);

assert.isFalse(cdAddStub.called);
assert.equal(collections.length, 0);

assert.isTrue(vpPutStub.called);
var firstPage = layout.grid[0];
assert.equal(firstPage.length, 2);
assert.equal(firstPage[0].id, 234);
assert.equal(firstPage[0].role, GridItemsFactory.TYPE.COLLECTION);
assert.equal(firstPage[1].name, 'app');
done();
};

var stub = sinon.stub(HomeState, 'getGrid', function(iterator, success) {
stub.restore();
iterator(page);
success();
});

window.asyncStorage.keys['evme-collectionsettings_idcollection'] = {};

startMigration();
});

});

0 comments on commit ed25745

Please sign in to comment.