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

Unified Diff: content/browser/intents/internal_web_intents_dispatcher_unittest.cc

Issue 9692017: An internal intents dispatcher useful for initiating an intent from the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add CONTENT_EXPORT Created 8 years, 9 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: content/browser/intents/internal_web_intents_dispatcher_unittest.cc
diff --git a/content/browser/intents/internal_web_intents_dispatcher_unittest.cc b/content/browser/intents/internal_web_intents_dispatcher_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a70a9f4ff99c3030b4d296c964c33fc3d1e92906
--- /dev/null
+++ b/content/browser/intents/internal_web_intents_dispatcher_unittest.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2012 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/bind.h"
+#include "base/utf_string_conversions.h"
+#include "content/browser/intents/intent_injector.h"
+#include "content/browser/intents/internal_web_intents_dispatcher.h"
+#include "content/browser/renderer_host/test_render_view_host.h"
+#include "content/browser/tab_contents/test_tab_contents.h"
+#include "webkit/glue/web_intent_data.h"
+#include "webkit/glue/web_intent_reply_data.h"
+
+class InternalWebIntentsDispatcherTest : public RenderViewHostTestHarness {
+ public:
+ InternalWebIntentsDispatcherTest() {
+ replied_ = 0;
+ }
+
+ ~InternalWebIntentsDispatcherTest() {}
+
+ void NotifyReply(webkit_glue::WebIntentReplyType reply_type,
+ const string16& data) {
+ notified_reply_type_ = reply_type;
+ notified_data_ = data;
+ }
+
+ void ReplySent(webkit_glue::WebIntentReplyType reply_type) {
+ replied_++;
+ }
+
+ int replied_;
+ string16 notified_data_;
+ webkit_glue::WebIntentReplyType notified_reply_type_;
+ scoped_ptr<content::WebContents> tab_contents_;
+};
+
+// Tests that the internal dispatcher correctly notifies
+// its callbacks of any reply messages.
+TEST_F(InternalWebIntentsDispatcherTest, NotifiesOnReply) {
+ webkit_glue::WebIntentData intent(ASCIIToUTF16("action"),
+ ASCIIToUTF16("type"),
+ ASCIIToUTF16("unserialized_data"));
+ InternalWebIntentsDispatcher* dispatcher = new InternalWebIntentsDispatcher(
+ intent, base::Bind(&InternalWebIntentsDispatcherTest::NotifyReply,
+ base::Unretained(this)));
+ dispatcher->RegisterReplyNotification(
+ base::Bind(&InternalWebIntentsDispatcherTest::ReplySent,
+ base::Unretained(this)));
+
+ dispatcher->DispatchIntent(contents());
+
+ dispatcher->SendReplyMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS,
+ ASCIIToUTF16("success"));
+
+ EXPECT_EQ(ASCIIToUTF16("success"), notified_data_);
+ EXPECT_EQ(1, replied_);
+ EXPECT_EQ(webkit_glue::WEB_INTENT_REPLY_SUCCESS, notified_reply_type_);
+}
« no previous file with comments | « content/browser/intents/internal_web_intents_dispatcher.cc ('k') | content/browser/intents/web_intents_dispatcher_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698