Removing flow to demote App Launcher to App Host, so app_host.exe can be deleted...
[chromium-blink-merge.git] / webkit / glue / web_intent_service_data_unittest.cc
blob6f7ffa9e52ad9e53a5d7ec7bc91f794f1a277308
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.
5 #include <string>
7 #include "base/utf_string_conversions.h"
8 #include "googleurl/src/gurl.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "webkit/glue/web_intent_service_data.h"
12 using webkit_glue::WebIntentServiceData;
14 namespace {
16 void Expect(
17 const std::string& action,
18 const std::string& type,
19 const std::string& scheme,
20 const std::string& url,
21 const std::string& title,
22 const WebIntentServiceData::Disposition disposition,
23 const WebIntentServiceData* intent) {
25 EXPECT_EQ(GURL(url), intent->service_url);
26 EXPECT_EQ(ASCIIToUTF16(action), intent->action);
27 EXPECT_EQ(ASCIIToUTF16(type), intent->type);
28 EXPECT_EQ(ASCIIToUTF16(scheme), intent->scheme);
29 EXPECT_EQ(ASCIIToUTF16(title), intent->title);
30 EXPECT_EQ(disposition, intent->disposition);
33 TEST(WebIntentServiceDataTest, Defaults) {
34 WebIntentServiceData intent;
35 EXPECT_EQ(string16(), intent.action);
36 EXPECT_EQ(string16(), intent.type);
37 EXPECT_EQ(string16(), intent.scheme);
38 EXPECT_EQ(string16(), intent.title);
39 EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, intent.disposition);
42 TEST(WebIntentServiceDataTest, ActionServicesEqual) {
44 WebIntentServiceData intent(
45 ASCIIToUTF16("http://webintents.org/share"),
46 ASCIIToUTF16("image/png"),
47 string16(),
48 GURL("http://abc.com/xyx.html"),
49 ASCIIToUTF16("Image Sharing Service"));
51 Expect(
52 "http://webintents.org/share",
53 "image/png",
54 std::string(),
55 "http://abc.com/xyx.html",
56 "Image Sharing Service",
57 WebIntentServiceData::DISPOSITION_WINDOW,
58 &intent);
61 TEST(WebIntentServiceDataTest, SchemeServicesEqual) {
63 WebIntentServiceData intent(
64 string16(),
65 string16(),
66 ASCIIToUTF16("mailto"),
67 GURL("http://abc.com/xyx.html"),
68 ASCIIToUTF16("Image Sharing Service"));
70 Expect(
71 "",
72 "",
73 "mailto",
74 "http://abc.com/xyx.html",
75 "Image Sharing Service",
76 WebIntentServiceData::DISPOSITION_WINDOW,
77 &intent);
80 TEST(WebIntentServiceDataTest, SetDisposition) {
82 // Test using the default disposition (window).
83 WebIntentServiceData intent;
84 EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, intent.disposition);
86 // Set the disposition to "inline", another supported disposition.
87 intent.setDisposition(ASCIIToUTF16("inline"));
88 EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, intent.disposition);
90 // "native" is a special internal disposition we use for
91 // "built-in" services. We don't allow the "native" disposition to be
92 // set via web-content (which is how this SetDisposition gets called).
93 // So after trying to set the value to "native" the disposition should
94 // remain unchanged.
95 intent.setDisposition(ASCIIToUTF16("native"));
96 EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, intent.disposition);
98 // Unrecognized values are ignored. When trying to set the value to "poodles"
99 // the disposition should remain unchanged.
100 intent.setDisposition(ASCIIToUTF16("poodles"));
101 EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, intent.disposition);
103 // Set the value back to "window" to confirm we can set back to
104 // the default disposition value, and to confirm setting still
105 // works after our special casing of the "native" and unrecognized values.
106 intent.setDisposition(ASCIIToUTF16("window"));
107 EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, intent.disposition);
110 } // namespace