diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-31 04:24:17 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-31 04:24:17 +0000 |
commit | 711abaeaaec2bb552d9fe161200778f449fd2da0 (patch) | |
tree | 043dec5763dbb378464f0a9d813b08892c62a40a /chrome/browser | |
parent | 2f7c97fec82e0a4bebdf0fced4cf9db7ac574497 (diff) | |
download | chromium_src-711abaeaaec2bb552d9fe161200778f449fd2da0.zip chromium_src-711abaeaaec2bb552d9fe161200778f449fd2da0.tar.gz chromium_src-711abaeaaec2bb552d9fe161200778f449fd2da0.tar.bz2 |
Adding API tests for getViews and infobars.
Also fixing a bug where the wrong window id was returned
back after creating the infobar, and changing html path param
when calling show() from htlpPath to path as requrested by aa.
TEST=See chrome_tests.gypi
BUG=26463
Review URL: http://codereview.chromium.org/1561003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43176 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
4 files changed, 56 insertions, 9 deletions
diff --git a/chrome/browser/extensions/extension_get_views_apitest.cc b/chrome/browser/extensions/extension_get_views_apitest.cc new file mode 100644 index 0000000..8f1ced3 --- /dev/null +++ b/chrome/browser/extensions/extension_get_views_apitest.cc @@ -0,0 +1,23 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/common/chrome_switches.h" + +#if defined(TOOLKIT_VIEWS) +// Need to port ExtensionInfoBarDelegate::CreateInfoBar() to other platforms. +// See http://crbug.com/39916 for details. +#define MAYBE_GetViews GetViews +#else +#define MAYBE_GetViews DISABLED_GetViews +#endif + +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_GetViews) { + // TODO(finnur): Remove once infobars are no longer experimental (bug 39511). + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableExperimentalExtensionApis); + + ASSERT_TRUE(RunExtensionTest("get_views")) << message_; +} diff --git a/chrome/browser/extensions/extension_infobar_apitest.cc b/chrome/browser/extensions/extension_infobar_apitest.cc new file mode 100644 index 0000000..776b3a2 --- /dev/null +++ b/chrome/browser/extensions/extension_infobar_apitest.cc @@ -0,0 +1,23 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/common/chrome_switches.h" + +#if defined(TOOLKIT_VIEWS) +// Need to port ExtensionInfoBarDelegate::CreateInfoBar() to other platforms. +// See http://crbug.com/39916 for details. +#define MAYBE_Infobars Infobars +#else +#define MAYBE_Infobars DISABLED_Infobars +#endif + +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Infobars) { + // TODO(finnur): Remove once infobars are no longer experimental (bug 39511). + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableExperimentalExtensionApis); + + ASSERT_TRUE(RunExtensionTest("infobars")) << message_; +} diff --git a/chrome/browser/extensions/extension_infobar_module.cc b/chrome/browser/extensions/extension_infobar_module.cc index 01eec16..73768fb 100644 --- a/chrome/browser/extensions/extension_infobar_module.cc +++ b/chrome/browser/extensions/extension_infobar_module.cc @@ -29,24 +29,25 @@ bool ShowInfoBarFunction::RunImpl() { Extension* extension = dispatcher()->GetExtension(); GURL url = extension->GetResourceURL(extension->url(), html_path); - Browser* browser = dispatcher()->GetCurrentBrowser(true); - if (!browser) { - error_ = keys::kNoCurrentWindowError; - return false; - } - + Browser* browser = NULL; TabContents* tab_contents = NULL; if (args->HasKey(keys::kTabId)) { int tab_id = -1; EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kTabId, &tab_id)); EXTENSION_FUNCTION_VALIDATE(ExtensionTabUtil::GetTabById( - tab_id, browser->profile(), true, // Allow infobar in incognito. - NULL, NULL, &tab_contents, NULL)); + tab_id, profile(), true, // Allow infobar in incognito. + &browser, NULL, &tab_contents, NULL)); } else { + browser = dispatcher()->GetCurrentBrowser(true); tab_contents = browser->GetSelectedTabContents(); } + if (!browser) { + error_ = keys::kNoCurrentWindowError; + return false; + } + if (!tab_contents) { error_ = keys::kTabNotFoundError; return false; diff --git a/chrome/browser/extensions/extension_infobar_module_constants.cc b/chrome/browser/extensions/extension_infobar_module_constants.cc index d628c48..1b0eef9 100644 --- a/chrome/browser/extensions/extension_infobar_module_constants.cc +++ b/chrome/browser/extensions/extension_infobar_module_constants.cc @@ -6,7 +6,7 @@ namespace extension_infobar_module_constants { -const wchar_t kHtmlPath[] = L"htmlPath"; +const wchar_t kHtmlPath[] = L"path"; const wchar_t kTabId[] = L"tabId"; const char kNoCurrentWindowError[] = "No current browser window was found"; |