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

Unified Diff: chrome/browser/extensions/api/tabs/tabs_test.cc

Issue 10697017: Tabs Extension: Implementation of tabs.duplicate api. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/tabs/tabs_test.cc
===================================================================
--- chrome/browser/extensions/api/tabs/tabs_test.cc (revision 142698)
+++ chrome/browser/extensions/api/tabs/tabs_test.cc (working copy)
@@ -547,3 +547,44 @@
browser()),
keys::kInvalidWindowStateError));
}
+
+IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) {
Aaron Boodman 2012/07/16 21:37:59 What about a test for when the extension has the p
SanjoyPal 2012/07/17 10:39:56 Done.
+ scoped_refptr<CreateTabFunction> create_tab_function(new CreateTabFunction());
+ // Without a callback the function will not generate a result.
+ create_tab_function->set_has_callback(true);
+
+ static const char kNewBlankTabArgs[] =
+ "[{\"url\": \"about:blank\"}]";
+
+ scoped_ptr<base::DictionaryValue> result(utils::ToDictionary(
+ utils::RunFunctionAndReturnResult(
+ create_tab_function.get(),
+ kNewBlankTabArgs,
+ browser())));
+
+ int tab_id = utils::GetInteger(result.get(), "id");
+ int tab_index = utils::GetInteger(result.get(), "index");
+
+ scoped_refptr<DuplicateTabFunction> duplicate_tab_function(
+ new DuplicateTabFunction());
+ scoped_refptr<extensions::Extension> empty_extension(
+ utils::CreateEmptyExtension());
+ duplicate_tab_function->set_extension(empty_extension.get());
+ // Without a callback the function will not generate a result.
+ duplicate_tab_function->set_has_callback(true);
+
+ scoped_ptr<base::DictionaryValue> duplicate_result(utils::ToDictionary(
+ utils::RunFunctionAndReturnResult(
+ duplicate_tab_function.get(), base::StringPrintf("[%u]", tab_id),
+ browser())));
+
+ int duplicate_tab_id = utils::GetInteger(duplicate_result.get(), "id");
+ int duplicate_tab_index = utils::GetInteger(duplicate_result.get(), "index");
+ // The test empty extension has no permissions, therefore it should get
+ // tab id of TYPE_INTEGER in the function result.
Aaron Boodman 2012/07/16 21:37:59 Comment is out of date.
SanjoyPal 2012/07/17 10:39:56 Done.
+ EXPECT_EQ(base::Value::TYPE_DICTIONARY, duplicate_result->GetType());
+ // Duplicate tab id should be different from the original tab id.
+ EXPECT_NE(tab_id, duplicate_tab_id);
+ EXPECT_EQ(tab_index + 1, duplicate_tab_index);
Aaron Boodman 2012/07/16 21:37:59 Can you test that URL, faviconURL, and title are *
SanjoyPal 2012/07/17 10:39:56 Done.
+}
+
Aaron Boodman 2012/07/16 21:37:59 extraneous blank line
SanjoyPal 2012/07/17 10:39:56 Done.

Powered by Google App Engine
This is Rietveld 408576698