OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/scoped_temp_dir.h" | 6 #include "base/scoped_temp_dir.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/intents/web_intents_registry.h" | 8 #include "chrome/browser/intents/web_intents_registry.h" |
9 #include "chrome/browser/webdata/web_data_service.h" | 9 #include "chrome/browser/webdata/web_data_service.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 WebIntentsRegistry::QueryID expected_id_; // QueryID callback is tied to. | 64 WebIntentsRegistry::QueryID expected_id_; // QueryID callback is tied to. |
65 std::vector<WebIntentData> intents_; // Result data from callback. | 65 std::vector<WebIntentData> intents_; // Result data from callback. |
66 }; | 66 }; |
67 | 67 |
68 TEST_F(WebIntentsRegistryTest, BasicTests) { | 68 TEST_F(WebIntentsRegistryTest, BasicTests) { |
69 WebIntentData intent; | 69 WebIntentData intent; |
70 intent.service_url = GURL("http://google.com"); | 70 intent.service_url = GURL("http://google.com"); |
71 intent.action = ASCIIToUTF16("share"); | 71 intent.action = ASCIIToUTF16("share"); |
72 intent.type = ASCIIToUTF16("image/*"); | 72 intent.type = ASCIIToUTF16("image/*"); |
| 73 intent.title = ASCIIToUTF16("Google's Sharing Service"); |
73 | 74 |
74 registry_.RegisterIntentProvider(intent); | 75 registry_.RegisterIntentProvider(intent); |
75 | 76 |
76 intent.type = ASCIIToUTF16("video/*"); | 77 intent.type = ASCIIToUTF16("video/*"); |
77 registry_.RegisterIntentProvider(intent); | 78 registry_.RegisterIntentProvider(intent); |
78 | 79 |
79 intent.action = ASCIIToUTF16("search"); | 80 intent.action = ASCIIToUTF16("search"); |
80 registry_.RegisterIntentProvider(intent); | 81 registry_.RegisterIntentProvider(intent); |
81 | 82 |
82 TestConsumer consumer; | 83 TestConsumer consumer; |
83 consumer.expected_id_ = registry_.GetIntentProviders(ASCIIToUTF16("share"), | 84 consumer.expected_id_ = registry_.GetIntentProviders(ASCIIToUTF16("share"), |
84 &consumer); | 85 &consumer); |
85 consumer.WaitForData(); | 86 consumer.WaitForData(); |
86 EXPECT_EQ(2U, consumer.intents_.size()); | 87 EXPECT_EQ(2U, consumer.intents_.size()); |
87 | 88 |
88 consumer.expected_id_ = registry_.GetIntentProviders(ASCIIToUTF16("search"), | 89 consumer.expected_id_ = registry_.GetIntentProviders(ASCIIToUTF16("search"), |
89 &consumer); | 90 &consumer); |
90 consumer.WaitForData(); | 91 consumer.WaitForData(); |
91 EXPECT_EQ(1U, consumer.intents_.size()); | 92 EXPECT_EQ(1U, consumer.intents_.size()); |
92 | 93 |
93 intent.action = ASCIIToUTF16("share"); | 94 intent.action = ASCIIToUTF16("share"); |
94 intent.type = ASCIIToUTF16("image/*"); | 95 intent.type = ASCIIToUTF16("image/*"); |
95 registry_.UnregisterIntentProvider(intent); | 96 registry_.UnregisterIntentProvider(intent); |
96 | 97 |
97 consumer.expected_id_ = registry_.GetIntentProviders(ASCIIToUTF16("share"), | 98 consumer.expected_id_ = registry_.GetIntentProviders(ASCIIToUTF16("share"), |
98 &consumer); | 99 &consumer); |
99 consumer.WaitForData(); | 100 consumer.WaitForData(); |
100 EXPECT_EQ(1U, consumer.intents_.size()); | 101 EXPECT_EQ(1U, consumer.intents_.size()); |
101 } | 102 } |
OLD | NEW |