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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/utf_string_conversions.h"
7 #include "content/browser/intents/intent_injector.h"
8 #include "content/browser/intents/internal_web_intents_dispatcher.h"
9 #include "content/browser/renderer_host/test_render_view_host.h"
10 #include "content/browser/tab_contents/test_tab_contents.h"
11 #include "webkit/glue/web_intent_data.h"
12 #include "webkit/glue/web_intent_reply_data.h"
13
14 class InternalWebIntentsDispatcherTest : public RenderViewHostTestHarness {
15 public:
16 InternalWebIntentsDispatcherTest() {
17 replied_ = 0;
18 }
19
20 ~InternalWebIntentsDispatcherTest() {}
21
22 void NotifyReply(webkit_glue::WebIntentReplyType reply_type,
23 const string16& data) {
24 notified_reply_type_ = reply_type;
25 notified_data_ = data;
26 }
27
28 void ReplySent(webkit_glue::WebIntentReplyType reply_type) {
29 replied_++;
30 }
31
32 int replied_;
33 string16 notified_data_;
34 webkit_glue::WebIntentReplyType notified_reply_type_;
35 scoped_ptr<content::WebContents> tab_contents_;
36 };
37
38 TEST_F(InternalWebIntentsDispatcherTest, SendIntent) {
James Hawkins 2012/03/12 23:19:11 Document what the test is doing.
Greg Billock 2012/03/12 23:52:22 Done.
39 webkit_glue::WebIntentData intent(ASCIIToUTF16("action"),
40 ASCIIToUTF16("type"),
41 ASCIIToUTF16("unserialized_data"));
42 InternalWebIntentsDispatcher* dispatcher = new InternalWebIntentsDispatcher(
43 intent, base::Bind(&InternalWebIntentsDispatcherTest::NotifyReply,
44 base::Unretained(this)));
45 dispatcher->RegisterReplyNotification(
46 base::Bind(&InternalWebIntentsDispatcherTest::ReplySent,
47 base::Unretained(this)));
48
49 dispatcher->DispatchIntent(contents());
50
51 dispatcher->SendReplyMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS,
52 ASCIIToUTF16("success"));
53
54 EXPECT_EQ(ASCIIToUTF16("success"), notified_data_);
55 EXPECT_EQ(1, replied_);
56 EXPECT_EQ(webkit_glue::WEB_INTENT_REPLY_SUCCESS, notified_reply_type_);
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698