OLD | NEW |
| (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 <string> | |
6 #include <vector> | |
7 | |
8 #include "base/command_line.h" | |
9 #include "base/utf_string_conversions.h" | |
10 #include "chrome/browser/intents/native_services.h" | |
11 #include "chrome/browser/intents/web_intents_util.h" | |
12 #include "chrome/common/chrome_switches.h" | |
13 #include "extensions/common/url_pattern.h" | |
14 #include "googleurl/src/gurl.h" | |
15 #include "testing/gtest/include/gtest/gtest.h" | |
16 #include "webkit/glue/web_intent_service_data.h" | |
17 | |
18 namespace { | |
19 | |
20 using web_intents::NativeServiceRegistry; | |
21 | |
22 TEST(NativeServiceRegistryTest, GetSupportedServices) { | |
23 #if !defined(ANDROID) | |
24 CommandLine::ForCurrentProcess()->AppendSwitch( | |
25 switches::kWebIntentsNativeServicesEnabled); | |
26 | |
27 NativeServiceRegistry::IntentServiceList services; | |
28 NativeServiceRegistry registry; | |
29 typedef NativeServiceRegistry::IntentServiceList::const_iterator Iter; | |
30 | |
31 registry.GetSupportedServices(ASCIIToUTF16("dothedew"), &services); | |
32 | |
33 ASSERT_EQ(0U, services.size()); | |
34 for (Iter it = services.begin(); it != services.end(); ++it) { | |
35 ADD_FAILURE() << "Unexpected handler for Dew: " << *it; | |
36 } | |
37 | |
38 registry.GetSupportedServices( | |
39 ASCIIToUTF16(web_intents::kActionPick), &services); | |
40 | |
41 EXPECT_EQ(1U, services.size()); | |
42 if (services.size() == 1) { | |
43 // Verify the service returned is for "pick". | |
44 EXPECT_EQ(ASCIIToUTF16(web_intents::kActionPick), services[0].action); | |
45 EXPECT_EQ(GURL(web_intents::kNativeFilePickerUrl), services[0].service_url); | |
46 } else { | |
47 for (Iter it = services.begin(); it != services.end(); ++it) { | |
48 ADD_FAILURE() << "Too many services for pick action: " << *it; | |
49 } | |
50 } | |
51 #endif | |
52 } | |
53 | |
54 TEST(NativeServiceRegistryTest, GetSupportedServicesDisabled) { | |
55 #if !defined(ANDROID) | |
56 NativeServiceRegistry::IntentServiceList services; | |
57 NativeServiceRegistry registry; | |
58 | |
59 registry.GetSupportedServices( | |
60 ASCIIToUTF16(web_intents::kActionPick), &services); | |
61 | |
62 ASSERT_EQ(0U, services.size()); | |
63 #endif | |
64 } | |
65 | |
66 } // namespace | |
OLD | NEW |