| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 ASSERT_TRUE(IntentsTable()->SetWebIntentService(intent)); | 182 ASSERT_TRUE(IntentsTable()->SetWebIntentService(intent)); |
| 183 EXPECT_TRUE(IntentsTable()->GetWebIntentServicesForURL( | 183 EXPECT_TRUE(IntentsTable()->GetWebIntentServicesForURL( |
| 184 UTF8ToUTF16(test_url.spec()), &intents)); | 184 UTF8ToUTF16(test_url.spec()), &intents)); |
| 185 ASSERT_EQ(2U, intents.size()); | 185 ASSERT_EQ(2U, intents.size()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 TEST_F(WebIntentsTableTest, DefaultServices) { | 188 TEST_F(WebIntentsTableTest, DefaultServices) { |
| 189 DefaultWebIntentService default_service; | 189 DefaultWebIntentService default_service; |
| 190 default_service.action = test_action; | 190 default_service.action = test_action; |
| 191 default_service.type = mime_image; | 191 default_service.type = mime_image; |
| 192 default_service.url_pattern.Parse(test_url.spec()); | 192 ASSERT_EQ(URLPattern::PARSE_SUCCESS, |
| 193 default_service.url_pattern.Parse(test_url.spec())); |
| 193 default_service.user_date = 1; | 194 default_service.user_date = 1; |
| 194 default_service.suppression = 4; | 195 default_service.suppression = 4; |
| 195 default_service.service_url = "service_url"; | 196 default_service.service_url = "service_url"; |
| 196 ASSERT_TRUE(IntentsTable()->SetDefaultService(default_service)); | 197 ASSERT_TRUE(IntentsTable()->SetDefaultService(default_service)); |
| 197 | 198 |
| 198 default_service.action = test_action_2; | 199 default_service.action = test_action_2; |
| 199 ASSERT_TRUE(IntentsTable()->SetDefaultService(default_service)); | 200 ASSERT_TRUE(IntentsTable()->SetDefaultService(default_service)); |
| 200 | 201 |
| 201 std::vector<DefaultWebIntentService> defaults; | 202 std::vector<DefaultWebIntentService> defaults; |
| 202 ASSERT_TRUE(IntentsTable()->GetDefaultServices(ASCIIToUTF16("no_action"), | 203 ASSERT_TRUE(IntentsTable()->GetDefaultServices(ASCIIToUTF16("no_action"), |
| 203 &defaults)); | 204 &defaults)); |
| 204 EXPECT_EQ(0U, defaults.size()); | 205 EXPECT_EQ(0U, defaults.size()); |
| 205 | 206 |
| 206 ASSERT_TRUE(IntentsTable()->GetDefaultServices(test_action, &defaults)); | 207 ASSERT_TRUE(IntentsTable()->GetDefaultServices(test_action, &defaults)); |
| 207 ASSERT_EQ(1U, defaults.size()); | 208 ASSERT_EQ(1U, defaults.size()); |
| 208 | 209 |
| 209 EXPECT_EQ(test_action, defaults[0].action); | 210 EXPECT_EQ(test_action, defaults[0].action); |
| 210 EXPECT_EQ(mime_image, defaults[0].type); | 211 EXPECT_EQ(mime_image, defaults[0].type); |
| 211 URLPattern test_pattern(URLPattern::SCHEME_HTTP, test_url.spec()); | 212 URLPattern test_pattern(URLPattern::SCHEME_HTTP, test_url.spec()); |
| 212 EXPECT_EQ(test_pattern, defaults[0].url_pattern); | 213 EXPECT_EQ(test_pattern.GetAsString(), defaults[0].url_pattern.GetAsString()); |
| 213 EXPECT_EQ(1, defaults[0].user_date); | 214 EXPECT_EQ(1, defaults[0].user_date); |
| 214 EXPECT_EQ(4, defaults[0].suppression); | 215 EXPECT_EQ(4, defaults[0].suppression); |
| 215 EXPECT_EQ("service_url", defaults[0].service_url); | 216 EXPECT_EQ("service_url", defaults[0].service_url); |
| 216 | 217 |
| 217 defaults.clear(); | 218 defaults.clear(); |
| 218 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults)); | 219 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults)); |
| 219 ASSERT_EQ(2U, defaults.size()); | 220 ASSERT_EQ(2U, defaults.size()); |
| 220 | 221 |
| 221 default_service.action = test_action; | 222 default_service.action = test_action; |
| 222 IntentsTable()->RemoveDefaultService(default_service); | 223 IntentsTable()->RemoveDefaultService(default_service); |
| 223 | 224 |
| 224 defaults.clear(); | 225 defaults.clear(); |
| 225 ASSERT_TRUE(IntentsTable()->GetDefaultServices(test_action, &defaults)); | 226 ASSERT_TRUE(IntentsTable()->GetDefaultServices(test_action, &defaults)); |
| 226 ASSERT_EQ(0U, defaults.size()); | 227 ASSERT_EQ(0U, defaults.size()); |
| 227 | 228 |
| 228 defaults.clear(); | 229 defaults.clear(); |
| 229 ASSERT_TRUE(IntentsTable()->GetDefaultServices(test_action_2, &defaults)); | 230 ASSERT_TRUE(IntentsTable()->GetDefaultServices(test_action_2, &defaults)); |
| 230 ASSERT_EQ(1U, defaults.size()); | 231 ASSERT_EQ(1U, defaults.size()); |
| 231 | 232 |
| 232 defaults.clear(); | 233 defaults.clear(); |
| 233 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults)); | 234 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults)); |
| 234 ASSERT_EQ(1U, defaults.size()); | 235 ASSERT_EQ(1U, defaults.size()); |
| 235 } | 236 } |
| 236 | 237 |
| 237 } // namespace | 238 } // namespace |
| OLD | NEW |