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 #33113 from mikehenrty/bug-1223374-bookmark-favico…
Browse files Browse the repository at this point in the history
…n-to-pinning

Bug 1223374 - Migrate bookmark_invalid_favicon_test.js to pinning the…
  • Loading branch information
mikehenrty committed Nov 10, 2015
2 parents f8357f6 + f242e9b commit c8c55fa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
24 changes: 24 additions & 0 deletions apps/homescreen/test/marionette/lib/homescreen.js
Expand Up @@ -14,6 +14,7 @@ Homescreen.URL = 'app://homescreen.gaiamobile.org';
Homescreen.Selectors = {
appsScrollable: '#apps-panel .scrollable',
apps: '#apps',
pages: '#pages',
icon: '#apps gaia-app-icon',
card: '#pages gaia-pin-card',
remove: '#remove',
Expand Down Expand Up @@ -114,6 +115,17 @@ Homescreen.prototype = {
Homescreen.Selectors.apps + ' [data-identifier*="' + identifier + '"]');
},

/**
* Fetch a card element on the homescreen by its identifier.
* For apps, the identifier is the manifestURL, or its manifestURL,
* followed by a '/' followed by its entry point. For pin, the
* identifier is the pinned URL.
*/
getCard: function(identifier) {
return this.client.findElement(
Homescreen.Selectors.pages + ' [data-id="' + identifier + '"]');
},

/**
* Fetch an icon element on the homescreen by its name.
*
Expand Down Expand Up @@ -191,6 +203,18 @@ Homescreen.prototype = {
});
},

/**
* Returns a homescreen card element's image URL.
*
* @param {Marionette.Element} card A homescreen card element reference.
*/
getCardImageUrl: function(card) {
return card.scriptWith(function(el) {
var icon = el.shadowRoot.querySelector('.icon-container i');
return icon.style.backgroundImage;
});
},

/**
* Waits for an icon's image URL to contain a certain value.
*
Expand Down
@@ -1,17 +1,16 @@
'use strict';
/* global __dirname */

var Bookmark = require('../../../../apps/system/test/marionette/lib/bookmark');
var Pinning = require(
'../../../../apps/system/test/marionette/lib/pinning_the_web');
var Server = require('../../../../shared/test/integration/server');

marionette('Homescreen - Bookmark Favicon Failure', function() {
var assert = require('assert');

var options = require(__dirname + '/client_options_bookmarks.js');
options.settings['dev.gaia.pinning_the_web'] = false;
var client = marionette.client({
profile: options
});
var bookmark, home, server, system;
marionette('Homescreen - Pinning Favicon Failure', function() {
var client = marionette.client();

var pinning, home, server, system;

suiteSetup(function(done) {
Server.create(__dirname + '/fixtures/invalid_favicon/',
Expand All @@ -29,21 +28,21 @@ marionette('Homescreen - Bookmark Favicon Failure', function() {
setup(function() {
home = client.loader.getAppClass('homescreen');
system = client.loader.getAppClass('system');
bookmark = new Bookmark(client, server);
pinning = new Pinning(client, server);
system.waitForFullyLoaded();
home.waitForLaunch();

url = server.url('sample.html');
client.switchToFrame();
bookmark.openAndSave(url);
pinning.openAndPinPage(url);

system.tapHome();
client.switchToFrame(system.getHomescreenIframe());
});

test('Invalid icons get default icon assigned', function() {
var icon = home.getIcon(url);
home.waitForIconImageUrl(icon, 'default');
var card = home.getCard(url);
assert.equal('', home.getCardImageUrl(card), 'Card has no bg image');
});

});

0 comments on commit c8c55fa

Please sign in to comment.