Chromium Code Reviews| Index: chrome/test/data/webui/md_history/history_synced_tabs_test.js |
| diff --git a/chrome/test/data/webui/md_history/history_synced_tabs_test.js b/chrome/test/data/webui/md_history/history_synced_tabs_test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b52d6ffe73f9cd4260cf5fd85d28cc26eb083801 |
| --- /dev/null |
| +++ b/chrome/test/data/webui/md_history/history_synced_tabs_test.js |
| @@ -0,0 +1,109 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('md_history.history_synced_tabs_test', function() { |
| + function createSession(name, windows) { |
| + return { |
| + collapsed: false, |
|
tsergeant
2016/03/09 04:36:50
Nit: Deindent these to 6 spaces
calamity
2016/03/10 04:18:25
Done.
|
| + deviceType: '', |
| + name: name, |
| + modifiedTime: 0, |
| + tag: '', |
| + windows: windows |
| + }; |
| + } |
| + |
| + function createWindow(tabUrls) { |
| + var tabs = []; |
| + for (var i in tabUrls) { |
| + tabs.push({ |
| + sessionId: 0, |
| + timestamp: 0, |
| + title: tabUrls[i], |
| + url: tabUrls[i] |
| + }); |
| + } |
| + |
| + return { |
| + tabs: tabs, |
| + userVisibleTimestamp: "A while ago" |
| + } |
| + } |
| + |
| + function registerTests() { |
| + suite('synced-tabs', function() { |
| + var element; |
| + var sidebarElement; |
| + |
| + suiteSetup(function() { |
| + element = $('history-synced-device-manager'); |
| + sidebarElement = $('history-side-bar'); |
| + }); |
| + |
| + test('sidebar displayed', function() { |
| + setForeignSessions([], false); |
| + assertTrue(sidebarElement.hidden); |
| + setForeignSessions([], true); |
| + assertFalse(sidebarElement.hidden); |
| + }); |
| + |
| + test('single card, single window', function(done) { |
| + var sessionList = [ |
| + createSession( |
| + 'Nexus 5', |
| + [createWindow(['http://www.google.com', 'http://example.com'])] |
| + ) |
| + ]; |
| + setForeignSessions(sessionList, true); |
| + |
| + flush(function() { |
| + var card = element.$$('history-synced-device-card'); |
| + assertEquals(2, card.tabs.length); |
| + done(); |
| + }); |
| + }); |
| + |
| + test('two cards, multiple windows', function(done) { |
| + var sessionList = [ |
| + createSession( |
| + 'Nexus 5', |
| + [createWindow(['http://www.google.com', 'http://example.com'])] |
| + ), |
| + createSession( |
| + 'Nexus 5', |
| + [ |
| + createWindow(['http://test.com']), |
| + createWindow(['http://www.gmail.com', 'http://badssl.com']) |
| + ] |
| + ), |
| + ]; |
| + setForeignSessions(sessionList, true); |
| + |
| + flush(function() { |
| + var cards = Polymer.dom(element.root) |
| + .querySelectorAll('history-synced-device-card'); |
| + assertEquals(2, cards.length); |
| + |
| + // Ensure separators between windows are added appropriately. |
| + assertEquals( |
| + 1, Polymer.dom(cards[0].root) |
| + .querySelectorAll('#window-separator') |
| + .length); |
| + assertEquals( |
| + 2, Polymer.dom(cards[1].root) |
| + .querySelectorAll('#window-separator') |
| + .length); |
| + done(); |
| + }); |
| + }); |
| + |
| + teardown(function() { |
| + element.syncedDevices = []; |
| + }); |
| + }); |
| + } |
| + return { |
| + registerTests: registerTests |
| + }; |
| +}); |