- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / app_list / start_page_browsertest.js
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6  * TestFixture for kiosk app settings WebUI testing.
7  * @extends {testing.Test}
8  * @constructor
9  **/
10 function AppListStartPageWebUITest() {}
11
12 AppListStartPageWebUITest.prototype = {
13   __proto__: testing.Test.prototype,
14
15   /**
16    * Browser to app launcher start page.
17    */
18   browsePreload: 'chrome://app-list/',
19
20   /**
21    * Recommend apps data.
22    * @private
23    */
24   recommendedApps_: [
25     {
26       'appId': 'app_id_1',
27       'textTitle': 'app 1',
28       'iconUrl': 'icon_url_1'
29     },
30     {
31       'appId': 'app_id_2',
32       'textTitle': 'app 2',
33       'iconUrl': 'icon_url_2'
34     },
35   ],
36
37   /** @override */
38   preLoad: function() {
39     this.makeAndRegisterMockHandler(['initialize', 'launchApp']);
40     this.mockHandler.stubs().initialize().will(callFunction(function() {
41       appList.startPage.setRecommendedApps(this.recommendedApps_);
42     }.bind(this)));
43     this.mockHandler.stubs().launchApp(ANYTHING);
44   }
45 };
46
47 TEST_F('AppListStartPageWebUITest', 'Basic', function() {
48   assertEquals(this.browsePreload, document.location.href);
49
50   var recommendedApp = $('start-page').querySelector('.recommended-apps');
51   assertEquals(this.recommendedApps_.length, recommendedApp.childElementCount);
52   for (var i = 0; i < recommendedApp.childElementCount; ++i) {
53     assertEquals(this.recommendedApps_[i].appId,
54                  recommendedApp.children[i].appId);
55   }
56 });
57
58 TEST_F('AppListStartPageWebUITest', 'ClickToLaunch', function() {
59   var recommendedApp = $('start-page').querySelector('.recommended-apps');
60   for (var i = 0; i < recommendedApp.childElementCount; ++i) {
61     this.mockHandler.expects(once()).launchApp(
62         [this.recommendedApps_[i].appId]);
63     cr.dispatchSimpleEvent(recommendedApp.children[i], 'click');
64   }
65 });