Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: chrome/renderer/extensions/extension_api_client_unittest.cc

Issue 180016: Extension API Renaming/Consistency changes (Closed)
Patch Set: render docs Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/extensions/docs/tabs.html ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/common/chrome_paths.h" 8 #include "chrome/common/chrome_paths.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/renderer/extensions/extension_process_bindings.h" 10 #include "chrome/renderer/extensions/extension_process_bindings.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 ExpectJsFail("chrome.windows.getLastFocused('abc');", 151 ExpectJsFail("chrome.windows.getLastFocused('abc');",
152 "Uncaught Error: Invalid value for argument 0. " 152 "Uncaught Error: Invalid value for argument 0. "
153 "Expected 'function' but got 'string'."); 153 "Expected 'function' but got 'string'.");
154 154
155 ExpectJsPass("chrome.windows.getLastFocused(function(){})", 155 ExpectJsPass("chrome.windows.getLastFocused(function(){})",
156 "windows.getLastFocused", "null"); 156 "windows.getLastFocused", "null");
157 } 157 }
158 158
159 TEST_F(ExtensionAPIClientTest, GetAllWindows) { 159 TEST_F(ExtensionAPIClientTest, GetAllWindows) {
160 ExpectJsFail("chrome.windows.getAll(true, function(){}, 20);", 160 ExpectJsFail("chrome.windows.getAll({populate: true}, function(){}, 20);",
161 "Uncaught Error: Too many arguments."); 161 "Uncaught Error: Too many arguments.");
162 162
163 ExpectJsFail("chrome.windows.getAll(1, function(){});", 163 ExpectJsFail("chrome.windows.getAll(1, function(){});",
164 "Uncaught Error: Invalid value for argument 0. " 164 "Uncaught Error: Invalid value for argument 0. "
165 "Expected 'boolean' but got 'integer'."); 165 "Expected 'object' but got 'integer'.");
166 166
167 ExpectJsPass("chrome.windows.getAll(true, function(){})", 167 ExpectJsPass("chrome.windows.getAll({populate:true}, function(){})",
168 "windows.getAll", "true"); 168 "windows.getAll", "{\"populate\":true}");
169 169
170 ExpectJsPass("chrome.windows.getAll(null, function(){})", 170 ExpectJsPass("chrome.windows.getAll(null, function(){})",
171 "windows.getAll", "null"); 171 "windows.getAll", "null");
172 172
173 ExpectJsPass("chrome.windows.getAll({}, function(){})",
174 "windows.getAll", "{}");
175
173 ExpectJsPass("chrome.windows.getAll(undefined, function(){})", 176 ExpectJsPass("chrome.windows.getAll(undefined, function(){})",
174 "windows.getAll", "null"); 177 "windows.getAll", "null");
175 } 178 }
176 179
177 TEST_F(ExtensionAPIClientTest, CreateWindow) { 180 TEST_F(ExtensionAPIClientTest, CreateWindow) {
178 ExpectJsFail("chrome.windows.create({url: 1}, function(){});", 181 ExpectJsFail("chrome.windows.create({url: 1}, function(){});",
179 "Uncaught Error: Invalid value for argument 0. Property " 182 "Uncaught Error: Invalid value for argument 0. Property "
180 "'url': Expected 'string' but got 'integer'."); 183 "'url': Expected 'string' but got 'integer'.");
181 ExpectJsFail("chrome.windows.create({left: 'foo'}, function(){});", 184 ExpectJsFail("chrome.windows.create({left: 'foo'}, function(){});",
182 "Uncaught Error: Invalid value for argument 0. Property " 185 "Uncaught Error: Invalid value for argument 0. Property "
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 "\"title\":\"a\",\"iconId\":0}]"); 531 "\"title\":\"a\",\"iconId\":0}]");
529 532
530 // Now try disablePageAction. 533 // Now try disablePageAction.
531 ExpectJsPass("chrome.pageActions.disableForTab(" 534 ExpectJsPass("chrome.pageActions.disableForTab("
532 "'dummy', {tabId: 0, url: 'http://foo/'});", 535 "'dummy', {tabId: 0, url: 'http://foo/'});",
533 "pageActions.disableForTab", 536 "pageActions.disableForTab",
534 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]"); 537 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]");
535 } 538 }
536 539
537 TEST_F(ExtensionAPIClientTest, ExpandToolstrip) { 540 TEST_F(ExtensionAPIClientTest, ExpandToolstrip) {
538 ExpectJsPass("chrome.toolstrip.expand(100, 'http://foo/')", 541 ExpectJsPass("chrome.toolstrip.expand({height:100, url:'http://foo/'})",
539 "toolstrip.expand", 542 "toolstrip.expand",
540 "[100,\"http://foo/\"]"); 543 "{\"height\":100,\"url\":\"http://foo/\"}");
541 ExpectJsPass("chrome.toolstrip.expand(100, null)", 544 ExpectJsPass("chrome.toolstrip.expand({height:100}, null)",
542 "toolstrip.expand", 545 "toolstrip.expand",
543 "[100,null]"); 546 "{\"height\":100}");
544 ExpectJsPass("chrome.toolstrip.expand(100, 'http://foo/', function(){})", 547 ExpectJsPass("chrome.toolstrip.expand({height:100,url:'http://foo/'}, "
548 "function(){})",
545 "toolstrip.expand", 549 "toolstrip.expand",
546 "[100,\"http://foo/\"]"); 550 "{\"height\":100,\"url\":\"http://foo/\"}");
547 551
548 ExpectJsFail("chrome.toolstrip.expand('100', 'http://foo/')", 552
553 ExpectJsFail("chrome.toolstrip.expand()",
554 "Uncaught Error: Parameter 0 is required.");
555 ExpectJsFail("chrome.toolstrip.expand(1)",
549 "Uncaught Error: Invalid value for argument 0. " 556 "Uncaught Error: Invalid value for argument 0. "
557 "Expected 'object' but got 'integer'.");
558 ExpectJsFail("chrome.toolstrip.expand({height:'100', url:'http://foo/'})",
559 "Uncaught Error: Invalid value for argument 0. "
560 "Property 'height': "
550 "Expected 'integer' but got 'string'."); 561 "Expected 'integer' but got 'string'.");
551 ExpectJsFail("chrome.toolstrip.expand(100, 100)", 562 ExpectJsFail("chrome.toolstrip.expand({height:100,url:100})",
563 "Uncaught Error: Invalid value for argument 0. Property 'url': "
564 "Expected 'string' but got 'integer'.");
565 ExpectJsFail("chrome.toolstrip.expand({height:100,'url':'http://foo/'}, 32)",
552 "Uncaught Error: Invalid value for argument 1. " 566 "Uncaught Error: Invalid value for argument 1. "
553 "Expected 'string' but got 'integer'.");
554 ExpectJsFail("chrome.toolstrip.expand(100, 'http://foo/', 32)",
555 "Uncaught Error: Invalid value for argument 2. "
556 "Expected 'function' but got 'integer'."); 567 "Expected 'function' but got 'integer'.");
557 } 568 }
558 569
559 TEST_F(ExtensionAPIClientTest, CollapseToolstrip) { 570 TEST_F(ExtensionAPIClientTest, CollapseToolstrip) {
560 ExpectJsPass("chrome.toolstrip.collapse('http://foo/')", 571 ExpectJsPass("chrome.toolstrip.collapse({url:'http://foo/'})",
561 "toolstrip.collapse", 572 "toolstrip.collapse",
562 "\"http://foo/\""); 573 "{\"url\":\"http://foo/\"}");
563 ExpectJsPass("chrome.toolstrip.collapse(null)", 574 ExpectJsPass("chrome.toolstrip.collapse(null)",
564 "toolstrip.collapse", 575 "toolstrip.collapse",
565 "null"); 576 "null");
566 ExpectJsPass("chrome.toolstrip.collapse('http://foo/', function(){})", 577 ExpectJsPass("chrome.toolstrip.collapse({url:'http://foo/'}, function(){})",
567 "toolstrip.collapse", 578 "toolstrip.collapse",
568 "\"http://foo/\""); 579 "{\"url\":\"http://foo/\"}");
569 580
581 ExpectJsFail("chrome.toolstrip.collapse(1)",
582 "Uncaught Error: Invalid value for argument 0. "
583 "Expected 'object' but got 'integer'.");
570 ExpectJsFail("chrome.toolstrip.collapse(100)", 584 ExpectJsFail("chrome.toolstrip.collapse(100)",
571 "Uncaught Error: Invalid value for argument 0. " 585 "Uncaught Error: Invalid value for argument 0. "
572 "Expected 'string' but got 'integer'."); 586 "Expected 'object' but got 'integer'.");
573 ExpectJsFail("chrome.toolstrip.collapse('http://foo/', 32)", 587 ExpectJsFail("chrome.toolstrip.collapse({url:'http://foo/'}, 32)",
574 "Uncaught Error: Invalid value for argument 1. " 588 "Uncaught Error: Invalid value for argument 1. "
575 "Expected 'function' but got 'integer'."); 589 "Expected 'function' but got 'integer'.");
576 } 590 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/tabs.html ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698