Commit 8bced11d authored by btolsch's avatar btolsch Committed by Commit Bot

[Media Router UI] Fix inconsistent filter state when search fails

When search fails, the filter list may show "No results" when it should
show the pseudo sink again.  This change addresses this by re-running
the filter after the search state has been cleared in the container.

Bug: 743126
Change-Id: I74993ab95d36d2a614b4257b6d2a9ff48f99a7db
Reviewed-on: https://chromium-review.googlesource.com/571115
Commit-Queue: Brandon Tolsch <btolsch@chromium.org>
Reviewed-by: default avatarDerek Cheng <imcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487240}
parent 1dfa5cac
......@@ -2271,6 +2271,7 @@ Polymer({
* indicating whether or not route creation was successful.
* Clearing |currentLaunchingSinkId_| hides the spinner indicating there is
* a route creation in progress and show the device icon instead.
* @param {boolean} creationSuccess Whether route creation succeeded.
*
* @private
*/
......@@ -2278,6 +2279,12 @@ Polymer({
this.pseudoSinkSearchState_ = null;
this.currentLaunchingSinkId_ = '';
this.pendingCreatedRouteId_ = '';
// If it was a search that failed we need to refresh the filtered sinks now
// that |pseudoSinkSearchState_| is null.
if (!creationSuccess &&
this.currentView_ == media_router.MediaRouterView.FILTER) {
this.filterSinks_(this.searchInputText_);
}
this.fire('report-route-creation', {success: creationSuccess});
},
......
......@@ -413,6 +413,34 @@ cr.define('media_router_container_search', function() {
});
});
test('route creation failure resets search', function(done) {
var searchInput = container.$$('#sink-search-input');
searchInput.value = foundSink.name;
chainOnAnimationPromise(function() {
var searchResults =
container.$$('#search-results').querySelectorAll('paper-item');
MockInteractions.tap(searchResults[0]);
// A found sink is added as part of the search but is removed right
// before the route failure is reported. The filter should revert to
// showing the pseudo sink when this is done.
container.allSinks = fakeSinkListWithPseudoSink.concat([foundSink]);
container.onReceiveSearchResult(foundSink.id);
container.allSinks = fakeSinkListWithPseudoSink;
container.onCreateRouteResponseReceived(pseudoSink.id, null, true);
assertEquals(null, container.pseudoSinkSearchState_);
setTimeout(function() {
checkCurrentView(media_router.MediaRouterView.FILTER);
searchResults =
container.$$('#search-results').querySelectorAll('paper-item');
assertTrue(container.searchResultsToShow_.some(function(sink) {
return sink.sinkItem.id == pseudoSink.id;
}));
done();
});
});
});
test('pseudo sink with empty domain is not shown', function(done) {
pseudoSink.domain = '';
// Trigger |allSinks| observer to be called again with new pseudo sink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment