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

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

Issue 160064: Push bookmarks.remove/removeAll polymorphism into c++. fix bookmarks id schema issues (Closed)
Patch Set: presubmit Created 11 years, 5 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/api/extension_api.json ('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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 ExpectJsPass("chrome.tabs.remove(2)", 421 ExpectJsPass("chrome.tabs.remove(2)",
422 "tabs.remove", "2"); 422 "tabs.remove", "2");
423 } 423 }
424 424
425 // Bookmark API tests 425 // Bookmark API tests
426 // TODO(erikkay) add more variations here 426 // TODO(erikkay) add more variations here
427 427
428 TEST_F(ExtensionAPIClientTest, CreateBookmark) { 428 TEST_F(ExtensionAPIClientTest, CreateBookmark) {
429 ExpectJsFail( 429 ExpectJsFail(
430 "chrome.bookmarks.create({parentId:'x', title:0}, function(){})", 430 "chrome.bookmarks.create({parentId:0, title:0}, function(){})",
431 "Uncaught Error: Invalid value for argument 0. " 431 "Uncaught Error: Invalid value for argument 0. "
432 "Property 'parentId': Expected 'integer' but got 'string', " 432 "Property 'parentId': Expected 'string' but got 'integer', "
433 "Property 'title': Expected 'string' but got 'integer'."); 433 "Property 'title': Expected 'string' but got 'integer'.");
434 434
435 ExpectJsPass( 435 ExpectJsPass(
436 "chrome.bookmarks.create({parentId:0, title:'x'}, function(){})", 436 "chrome.bookmarks.create({parentId:'0', title:'x'}, function(){})",
437 "bookmarks.create", 437 "bookmarks.create",
438 "{\"parentId\":0,\"title\":\"x\"}"); 438 "{\"parentId\":\"0\",\"title\":\"x\"}");
439 } 439 }
440 440
441 TEST_F(ExtensionAPIClientTest, GetBookmarks) { 441 TEST_F(ExtensionAPIClientTest, GetBookmarks) {
442 ExpectJsPass("chrome.bookmarks.get(0, function(){});", 442 ExpectJsPass("chrome.bookmarks.get('0', function(){});",
443 "bookmarks.get", 443 "bookmarks.get",
444 "0"); 444 "\"0\"");
445 ExpectJsPass("chrome.bookmarks.get([0,1,2,3], function(){});", 445 ExpectJsPass("chrome.bookmarks.get(['0','1','2','3'], function(){});",
446 "bookmarks.get", 446 "bookmarks.get",
447 "[0,1,2,3]"); 447 "[\"0\",\"1\",\"2\",\"3\"]");
448 ExpectJsFail("chrome.bookmarks.get(null, function(){});", 448 ExpectJsFail("chrome.bookmarks.get(null, function(){});",
449 "Uncaught Error: Parameter 0 is required."); 449 "Uncaught Error: Parameter 0 is required.");
450 // TODO(erikkay) This is succeeding, when it should fail. 450 // TODO(erikkay) This is succeeding, when it should fail.
451 // BUG=13719 451 // BUG=13719
452 #if 0 452 #if 0
453 ExpectJsFail("chrome.bookmarks.get({}, function(){});", 453 ExpectJsFail("chrome.bookmarks.get({}, function(){});",
454 "Uncaught Error: Invalid value for argument 0. " 454 "Uncaught Error: Invalid value for argument 0. "
455 "Expected 'array' but got 'object'."); 455 "Expected 'array' but got 'object'.");
456 #endif 456 #endif
457 } 457 }
458 458
459 TEST_F(ExtensionAPIClientTest, GetBookmarkChildren) { 459 TEST_F(ExtensionAPIClientTest, GetBookmarkChildren) {
460 ExpectJsPass("chrome.bookmarks.getChildren(42, function(){});", 460 ExpectJsPass("chrome.bookmarks.getChildren('42', function(){});",
461 "bookmarks.getChildren", 461 "bookmarks.getChildren",
462 "42"); 462 "\"42\"");
463 } 463 }
464 464
465 TEST_F(ExtensionAPIClientTest, GetBookmarkTree) { 465 TEST_F(ExtensionAPIClientTest, GetBookmarkTree) {
466 ExpectJsPass("chrome.bookmarks.getTree(function(){});", 466 ExpectJsPass("chrome.bookmarks.getTree(function(){});",
467 "bookmarks.getTree", 467 "bookmarks.getTree",
468 "null"); 468 "null");
469 } 469 }
470 470
471 TEST_F(ExtensionAPIClientTest, SearchBookmarks) { 471 TEST_F(ExtensionAPIClientTest, SearchBookmarks) {
472 ExpectJsPass("chrome.bookmarks.search('hello',function(){});", 472 ExpectJsPass("chrome.bookmarks.search('hello',function(){});",
473 "bookmarks.search", 473 "bookmarks.search",
474 "\"hello\""); 474 "\"hello\"");
475 } 475 }
476 476
477 TEST_F(ExtensionAPIClientTest, RemoveBookmark) { 477 TEST_F(ExtensionAPIClientTest, RemoveBookmark) {
478 ExpectJsPass("chrome.bookmarks.remove(42);", 478 ExpectJsPass("chrome.bookmarks.remove('42');",
479 "bookmarks.remove", 479 "bookmarks.remove",
480 "[42,false]"); 480 "\"42\"");
481 } 481 }
482 482
483 TEST_F(ExtensionAPIClientTest, RemoveBookmarkTree) { 483 TEST_F(ExtensionAPIClientTest, RemoveBookmarkTree) {
484 ExpectJsPass("chrome.bookmarks.removeTree(42);", 484 ExpectJsPass("chrome.bookmarks.removeTree('42');",
485 "bookmarks.removeTree", 485 "bookmarks.removeTree",
486 "[42,true]"); 486 "\"42\"");
487 } 487 }
488 488
489 TEST_F(ExtensionAPIClientTest, MoveBookmark) { 489 TEST_F(ExtensionAPIClientTest, MoveBookmark) {
490 ExpectJsPass("chrome.bookmarks.move(42,{parentId:1,index:0});", 490 ExpectJsPass("chrome.bookmarks.move('42',{parentId:'1',index:0});",
491 "bookmarks.move", 491 "bookmarks.move",
492 "[42,{\"parentId\":1,\"index\":0}]"); 492 "[\"42\",{\"parentId\":\"1\",\"index\":0}]");
493 } 493 }
494 494
495 TEST_F(ExtensionAPIClientTest, SetBookmarkTitle) { 495 TEST_F(ExtensionAPIClientTest, SetBookmarkTitle) {
496 ExpectJsPass("chrome.bookmarks.update(42,{title:'x'});", 496 ExpectJsPass("chrome.bookmarks.update('42',{title:'x'});",
497 "bookmarks.update", 497 "bookmarks.update",
498 "[42,{\"title\":\"x\"}]"); 498 "[\"42\",{\"title\":\"x\"}]");
499 } 499 }
500 500
501 TEST_F(ExtensionAPIClientTest, EnablePageAction) { 501 TEST_F(ExtensionAPIClientTest, EnablePageAction) {
502 // Basic old-school enablePageAction call. 502 // Basic old-school enablePageAction call.
503 ExpectJsPass("chrome.pageActions.enableForTab(" 503 ExpectJsPass("chrome.pageActions.enableForTab("
504 "\"dummy\", {tabId: 0, url: \"http://foo/\"});", 504 "'dummy', {tabId: 0, url: 'http://foo/'});",
505 "pageActions.enableForTab", 505 "pageActions.enableForTab",
506 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]"); 506 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]");
507 // Try both optional parameters (title and iconId). 507 // Try both optional parameters (title and iconId).
508 ExpectJsPass("chrome.pageActions.enableForTab(" 508 ExpectJsPass("chrome.pageActions.enableForTab("
509 "\"dummy\", {tabId: 0, url: \"http://foo/\"," 509 "'dummy', {tabId: 0, url: 'http://foo/',"
510 "title: \"a\", iconId: 0});", 510 "title: 'a', iconId: 0});",
511 "pageActions.enableForTab", 511 "pageActions.enableForTab",
512 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"," 512 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\","
513 "\"title\":\"a\",\"iconId\":0}]"); 513 "\"title\":\"a\",\"iconId\":0}]");
514 514
515 // Now try disablePageAction. 515 // Now try disablePageAction.
516 ExpectJsPass("chrome.pageActions.disableForTab(" 516 ExpectJsPass("chrome.pageActions.disableForTab("
517 "\"dummy\", {tabId: 0, url: \"http://foo/\"});", 517 "'dummy', {tabId: 0, url: 'http://foo/'});",
518 "pageActions.disableForTab", 518 "pageActions.disableForTab",
519 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]"); 519 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]");
520 } 520 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/extension_api.json ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698