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

Unified Diff: chrome/test/ppapi/ppapi_test.cc

Issue 10826164: Add infobar for PPAPI broker usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/ppapi/ppapi_test.h ('k') | ppapi/tests/test_broker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/ppapi/ppapi_test.cc
diff --git a/chrome/test/ppapi/ppapi_test.cc b/chrome/test/ppapi/ppapi_test.cc
index a3745bc2178f3bce8bdf013552bb22cdb0c47ba6..5e00f8b7a87e46cdca7d71fe5f3cc8119cfc1683 100644
--- a/chrome/test/ppapi/ppapi_test.cc
+++ b/chrome/test/ppapi/ppapi_test.cc
@@ -12,14 +12,21 @@
#include "base/string_util.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h"
+#include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
+#include "chrome/browser/content_settings/host_content_settings_map.h"
+#include "chrome/browser/infobars/infobar.h"
+#include "chrome/browser/infobars/infobar_tab_helper.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/test_launcher_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/dom_operation_notification_details.h"
#include "content/public/test/test_renderer_host.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h"
@@ -73,6 +80,41 @@ void PPAPITestMessageHandler::Reset() {
message_.clear();
}
+PPAPITestBase::InfoBarObserver::InfoBarObserver() {
+ registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
+ content::NotificationService::AllSources());
+}
+
+PPAPITestBase::InfoBarObserver::~InfoBarObserver() {
+ EXPECT_EQ(0u, expected_infobars_.size()) << "Missing an expected infobar";
+}
+
+void PPAPITestBase::InfoBarObserver::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ ASSERT_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, type);
+ InfoBarDelegate* info_bar_delegate =
+ content::Details<InfoBarAddedDetails>(details).ptr();
+ ConfirmInfoBarDelegate* confirm_info_bar_delegate =
+ info_bar_delegate->AsConfirmInfoBarDelegate();
+ ASSERT_TRUE(confirm_info_bar_delegate);
+
+ ASSERT_FALSE(expected_infobars_.empty()) << "Unexpected infobar";
+ if (expected_infobars_.front())
+ confirm_info_bar_delegate->Accept();
+ else
+ confirm_info_bar_delegate->Cancel();
+ expected_infobars_.pop_front();
+
+ // TODO(bauerb): We should close the infobar.
+}
+
+void PPAPITestBase::InfoBarObserver::ExpectInfoBarAndAccept(
+ bool should_accept) {
+ expected_infobars_.push_back(should_accept);
+}
+
PPAPITestBase::PPAPITestBase() {
}
@@ -97,6 +139,12 @@ void PPAPITestBase::SetUpCommandLine(CommandLine* command_line) {
command_line->AppendSwitch(switches::kDisableSmoothScrolling);
}
+void PPAPITestBase::SetUpOnMainThread() {
+ // Always allow access to the PPAPI broker.
+ browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
+ CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_ALLOW);
+}
+
GURL PPAPITestBase::GetTestFileUrl(const std::string& test_case) {
FilePath test_path;
EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_path));
@@ -302,3 +350,7 @@ std::string PPAPINaClTestDisallowedSockets::BuildQuery(
test_case.c_str());
}
+void PPAPIBrokerInfoBarTest::SetUpOnMainThread() {
+ // The default content setting for the PPAPI broker is ASK. We purposefully
+ // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way.
+}
« no previous file with comments | « chrome/test/ppapi/ppapi_test.h ('k') | ppapi/tests/test_broker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698