Chromium Code Reviews| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | |
| 7 #include <vector> | |
| 6 | 8 |
| 7 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 8 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| 9 #include "base/string16.h" | 11 #include "base/string16.h" |
| 10 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/intents/default_web_intent_service.h" | |
| 11 #include "chrome/browser/webdata/web_database.h" | 14 #include "chrome/browser/webdata/web_database.h" |
| 12 #include "chrome/browser/webdata/web_intents_table.h" | 15 #include "chrome/browser/webdata/web_intents_table.h" |
| 13 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 14 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "webkit/glue/web_intent_service_data.h" | 19 #include "webkit/glue/web_intent_service_data.h" |
| 17 | 20 |
| 18 using webkit_glue::WebIntentServiceData; | 21 using webkit_glue::WebIntentServiceData; |
| 19 | 22 |
| 20 namespace { | 23 namespace { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 UTF8ToUTF16(test_url_fake.spec()), &intents)); | 178 UTF8ToUTF16(test_url_fake.spec()), &intents)); |
| 176 EXPECT_EQ(0U, intents.size()); | 179 EXPECT_EQ(0U, intents.size()); |
| 177 | 180 |
| 178 intent.action = test_action_2; | 181 intent.action = test_action_2; |
| 179 ASSERT_TRUE(IntentsTable()->SetWebIntentService(intent)); | 182 ASSERT_TRUE(IntentsTable()->SetWebIntentService(intent)); |
| 180 EXPECT_TRUE(IntentsTable()->GetWebIntentServicesForURL( | 183 EXPECT_TRUE(IntentsTable()->GetWebIntentServicesForURL( |
| 181 UTF8ToUTF16(test_url.spec()), &intents)); | 184 UTF8ToUTF16(test_url.spec()), &intents)); |
| 182 ASSERT_EQ(2U, intents.size()); | 185 ASSERT_EQ(2U, intents.size()); |
| 183 } | 186 } |
| 184 | 187 |
| 188 TEST_F(WebIntentsTableTest, DefaultServices) { | |
| 189 DefaultWebIntentService default_service; | |
| 190 default_service.action = ASCIIToUTF16("action"); | |
|
groby-ooo-7-16
2012/02/08 23:18:38
nit: Might want to use the pre-defined constants a
Greg Billock
2012/02/08 23:34:06
ah, nice. yes.
| |
| 191 default_service.type = ASCIIToUTF16("mime/type"); | |
| 192 default_service.url_prefix = "url_prefix"; | |
| 193 default_service.user_date = 1; | |
| 194 default_service.suppression = 4; | |
| 195 default_service.service_url = "service_url"; | |
| 196 default_service.extension_url = "extension_url"; | |
| 197 ASSERT_TRUE(IntentsTable()->SetDefaultService(default_service)); | |
| 198 | |
| 199 default_service.action = ASCIIToUTF16("action2"); | |
| 200 ASSERT_TRUE(IntentsTable()->SetDefaultService(default_service)); | |
| 201 | |
| 202 std::vector<DefaultWebIntentService> defaults; | |
| 203 ASSERT_TRUE(IntentsTable()->GetDefaultServices(ASCIIToUTF16("no_action"), | |
| 204 &defaults)); | |
| 205 EXPECT_EQ(0U, defaults.size()); | |
| 206 | |
| 207 ASSERT_TRUE(IntentsTable()->GetDefaultServices(ASCIIToUTF16("action"), | |
| 208 &defaults)); | |
| 209 ASSERT_EQ(1U, defaults.size()); | |
| 210 | |
| 211 EXPECT_EQ(ASCIIToUTF16("action"), defaults[0].action); | |
| 212 EXPECT_EQ(ASCIIToUTF16("mime/type"), defaults[0].type); | |
| 213 EXPECT_EQ("url_prefix", defaults[0].url_prefix); | |
| 214 EXPECT_EQ(1, defaults[0].user_date); | |
| 215 EXPECT_EQ(4, defaults[0].suppression); | |
| 216 EXPECT_EQ("service_url", defaults[0].service_url); | |
| 217 EXPECT_EQ("extension_url", defaults[0].extension_url); | |
| 218 } | |
| 219 | |
| 185 } // namespace | 220 } // namespace |
| OLD | NEW |