| 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 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/webdata/web_database.h" | 11 #include "chrome/browser/webdata/web_database.h" |
| 12 #include "chrome/browser/webdata/web_intents_table.h" | 12 #include "chrome/browser/webdata/web_intents_table.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "webkit/glue/web_intent_service_data.h" | 16 #include "webkit/glue/web_intent_service_data.h" |
| 17 | 17 |
| 18 using webkit_glue::WebIntentServiceData; | 18 using webkit_glue::WebIntentServiceData; |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 GURL test_url("http://google.com/"); | 22 GURL test_url("http://google.com/"); |
| 23 GURL test_url_fake("http://fakegoogle.com/"); |
| 23 string16 test_action = ASCIIToUTF16("http://webintents.org/intents/share"); | 24 string16 test_action = ASCIIToUTF16("http://webintents.org/intents/share"); |
| 24 string16 test_action_2 = ASCIIToUTF16("http://webintents.org/intents/view"); | 25 string16 test_action_2 = ASCIIToUTF16("http://webintents.org/intents/view"); |
| 25 string16 test_title = ASCIIToUTF16("Test WebIntent"); | 26 string16 test_title = ASCIIToUTF16("Test WebIntent"); |
| 26 string16 test_title_2 = ASCIIToUTF16("Test WebIntent #2"); | 27 string16 test_title_2 = ASCIIToUTF16("Test WebIntent #2"); |
| 27 string16 mime_image = ASCIIToUTF16("image/*"); | 28 string16 mime_image = ASCIIToUTF16("image/*"); |
| 28 string16 mime_video = ASCIIToUTF16("video/*"); | 29 string16 mime_video = ASCIIToUTF16("video/*"); |
| 29 | 30 |
| 30 WebIntentServiceData MakeIntentService(const GURL& url, | 31 WebIntentServiceData MakeIntentService(const GURL& url, |
| 31 const string16& action, | 32 const string16& action, |
| 32 const string16& type, | 33 const string16& type, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 std::vector<WebIntentServiceData> services; | 151 std::vector<WebIntentServiceData> services; |
| 151 EXPECT_TRUE(IntentsTable()->GetAllWebIntents(&services)); | 152 EXPECT_TRUE(IntentsTable()->GetAllWebIntents(&services)); |
| 152 ASSERT_EQ(2U, services.size()); | 153 ASSERT_EQ(2U, services.size()); |
| 153 | 154 |
| 154 if (services[0].disposition == WebIntentServiceData::DISPOSITION_WINDOW) | 155 if (services[0].disposition == WebIntentServiceData::DISPOSITION_WINDOW) |
| 155 std::swap(services[0], services[1]); | 156 std::swap(services[0], services[1]); |
| 156 | 157 |
| 157 EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, services[0].disposition); | 158 EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, services[0].disposition); |
| 158 EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, services[1].disposition); | 159 EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, services[1].disposition); |
| 159 } | 160 } |
| 161 |
| 162 TEST_F(WebIntentsTableTest, GetByURL) { |
| 163 WebIntentServiceData intent = MakeIntentService( |
| 164 test_url, test_action, mime_image, test_title); |
| 165 ASSERT_TRUE(IntentsTable()->SetWebIntent(intent)); |
| 166 |
| 167 std::vector<WebIntentServiceData> intents; |
| 168 EXPECT_TRUE(IntentsTable()->GetWebIntentsForURL( |
| 169 UTF8ToUTF16(test_url.spec()), &intents)); |
| 170 ASSERT_EQ(1U, intents.size()); |
| 171 EXPECT_EQ(intent, intents[0]); |
| 172 |
| 173 intents.clear(); |
| 174 EXPECT_TRUE(IntentsTable()->GetWebIntentsForURL( |
| 175 UTF8ToUTF16(test_url_fake.spec()), &intents)); |
| 176 EXPECT_EQ(0U, intents.size()); |
| 177 |
| 178 intent.action = test_action_2; |
| 179 ASSERT_TRUE(IntentsTable()->SetWebIntent(intent)); |
| 180 EXPECT_TRUE(IntentsTable()->GetWebIntentsForURL( |
| 181 UTF8ToUTF16(test_url.spec()), &intents)); |
| 182 ASSERT_EQ(2U, intents.size()); |
| 183 } |
| 184 |
| 160 } // namespace | 185 } // namespace |
| OLD | NEW |