Index: chrome/test/data/webui/media_router/media_router_header_tests.js |
diff --git a/chrome/test/data/webui/media_router/media_router_header_tests.js b/chrome/test/data/webui/media_router/media_router_header_tests.js |
index f82ef68ca6232b75c72fc3513339fe538b1d089c..2e63e30a846f39915c60a0cb51d9bc6d25ac9f6d 100644 |
--- a/chrome/test/data/webui/media_router/media_router_header_tests.js |
+++ b/chrome/test/data/webui/media_router/media_router_header_tests.js |
@@ -20,7 +20,8 @@ cr.define('media_router_header', function() { |
'arrow-drop-icon', |
'back-button', |
'close-button', |
- 'header-text' |
+ 'header-text', |
+ 'user-email-container', |
]; |
// Checks whether the current icon matches the icon used for the view. |
@@ -30,8 +31,10 @@ cr.define('media_router_header', function() { |
}; |
// Checks whether |element| is hidden. |
+ // An element is considered hidden if it does not exist (e.g. unstamped) |
+ // or its |hidden| property is |false|. |
var checkElementHidden = function(hidden, element) { |
- assertEquals(hidden, element.hidden); |
+ assertEquals(hidden, !element || element.hidden); |
}; |
// Checks whether the elements specified in |elementIdList| are visible. |
@@ -46,18 +49,24 @@ cr.define('media_router_header', function() { |
} |
}; |
+ // Checks whether |expected| and the text in the |element| are equal. |
+ var checkElementText = function(expected, element) { |
+ assertEquals(expected.trim(), element.textContent.trim()); |
+ }; |
+ |
// Import media_router_header.html before running suite. |
suiteSetup(function() { |
return PolymerTest.importHtml( |
- 'chrome://media-router/elements/media_router_header/' + |
- 'media_router_header.html'); |
+ 'chrome://media-router/elements/media_router_container/' + |
+ 'media_router_container.html'); |
}); |
// Initialize an media-router-header before each test. |
setup(function(done) { |
PolymerTest.clearBody(); |
- header = document.createElement('media-router-header'); |
- document.body.appendChild(header); |
+ container = document.createElement('media-router-container'); |
+ document.body.appendChild(container); |
+ header = container.$['container-header']; |
// Allow for the media router header to be created and attached. |
setTimeout(done); |
@@ -137,6 +146,16 @@ cr.define('media_router_header', function() { |
done(); |
}); |
+ // Tests for 'header-height-changed' event firing when the header changes |
+ // if email is shown. |
+ test('header height changed with email shown', function(done) { |
+ header.addEventListener('header-height-changed', function() { |
+ done(); |
+ }); |
+ header.userEmail = 'user@example.com'; |
+ header.showEmail = true; |
+ }); |
+ |
// Tests the |computeArrowDropIcon_| function. |
test('compute arrow drop icon', function() { |
assertEquals('arrow-drop-up', |
@@ -181,6 +200,33 @@ cr.define('media_router_header', function() { |
'close-button', |
'header-text']); |
}); |
+ |
+ test('visibility and style of UI depending on email', function(done) { |
apacible
2016/02/25 00:16:02
nit: Add comment for test, e.g. "// Tests that the
amp
2016/02/25 03:01:15
Done.
|
+ header.userEmail = 'user@example.com'; |
+ header.showEmail = true; |
+ setTimeout(function() { |
+ assertEquals(header.headerWithEmailHeight_, header.offsetHeight) |
+ |
+ assertFalse(header.$$('#user-email-container').hidden); |
+ checkElementText( |
+ header.userEmail, |
+ header.$$('#user-email-container')); |
+ done(); |
+ }); |
+ }); |
+ |
+ test('visibility and style of UI for empty email', function(done) { |
+ // Verify no email is shown if email is empty |
apacible
2016/02/25 00:16:02
nit: Move this comment right above the previous li
amp
2016/02/25 03:01:15
Done.
|
+ header.userEmail = undefined; |
+ header.showEmail = true; |
+ setTimeout(function() { |
+ assertNotEquals(header.headerWithEmailHeight_, header.offsetHeight) |
+ checkElementText( |
+ '', |
+ header.$$('#user-email-container')); |
+ done(); |
+ }); |
+ }); |
}); |
} |