| 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/files/scoped_temp_dir.h" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/intents/default_web_intent_service.h" | 13 #include "chrome/browser/intents/default_web_intent_service.h" |
| 14 #include "chrome/browser/webdata/web_database.h" | 14 #include "chrome/browser/webdata/web_database.h" |
| 15 #include "chrome/browser/webdata/web_intents_table.h" | 15 #include "chrome/browser/webdata/web_intents_table.h" |
| 16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "webkit/glue/web_intent_service_data.h" | 19 #include "webkit/glue/web_intent_service_data.h" |
| 20 | 20 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 66 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 67 ASSERT_EQ(sql::INIT_OK, | 67 ASSERT_EQ(sql::INIT_OK, |
| 68 db_.Init(temp_dir_.path().AppendASCII("TestWebDatabase.db"))); | 68 db_.Init(temp_dir_.path().AppendASCII("TestWebDatabase.db"))); |
| 69 } | 69 } |
| 70 | 70 |
| 71 WebIntentsTable* IntentsTable() { | 71 WebIntentsTable* IntentsTable() { |
| 72 return db_.GetWebIntentsTable(); | 72 return db_.GetWebIntentsTable(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 WebDatabase db_; | 75 WebDatabase db_; |
| 76 ScopedTempDir temp_dir_; | 76 base::ScopedTempDir temp_dir_; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 // Test we can add, retrieve, and remove intent services from the database. | 79 // Test we can add, retrieve, and remove intent services from the database. |
| 80 TEST_F(WebIntentsTableTest, ActionIntents) { | 80 TEST_F(WebIntentsTableTest, ActionIntents) { |
| 81 std::vector<WebIntentServiceData> services; | 81 std::vector<WebIntentServiceData> services; |
| 82 | 82 |
| 83 // By default, no intent services exist. | 83 // By default, no intent services exist. |
| 84 EXPECT_TRUE(IntentsTable()->GetWebIntentServices(test_action, &services)); | 84 EXPECT_TRUE(IntentsTable()->GetWebIntentServices(test_action, &services)); |
| 85 EXPECT_EQ(0U, services.size()); | 85 EXPECT_EQ(0U, services.size()); |
| 86 | 86 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 default_service.service_url = "service_url3"; | 359 default_service.service_url = "service_url3"; |
| 360 ASSERT_TRUE(IntentsTable()->SetDefaultService(default_service)); | 360 ASSERT_TRUE(IntentsTable()->SetDefaultService(default_service)); |
| 361 | 361 |
| 362 std::vector<DefaultWebIntentService> defaults; | 362 std::vector<DefaultWebIntentService> defaults; |
| 363 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults)); | 363 ASSERT_TRUE(IntentsTable()->GetAllDefaultServices(&defaults)); |
| 364 ASSERT_EQ(1U, defaults.size()); | 364 ASSERT_EQ(1U, defaults.size()); |
| 365 EXPECT_EQ("service_url3", defaults[0].service_url); | 365 EXPECT_EQ("service_url3", defaults[0].service_url); |
| 366 } | 366 } |
| 367 | 367 |
| 368 } // namespace | 368 } // namespace |
| OLD | NEW |