Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/browser/webdata/web_intents_table_unittest.cc

Issue 7624012: First pass on intents options UI. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add comments, fix CSS, etc. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 16
17 namespace { 17 namespace {
18 18
19 GURL test_url("http://google.com/"); 19 GURL test_url("http://google.com/");
20 string16 test_action = ASCIIToUTF16("http://webintents.org/intents/share"); 20 string16 test_action = ASCIIToUTF16("http://webintents.org/intents/share");
21 string16 test_action_2 = ASCIIToUTF16("http://webintents.org/intents/view"); 21 string16 test_action_2 = ASCIIToUTF16("http://webintents.org/intents/view");
22 string16 mime_image = ASCIIToUTF16("image/*"); 22 string16 mime_image = ASCIIToUTF16("image/*");
23 string16 mime_video = ASCIIToUTF16("video/*"); 23 string16 mime_video = ASCIIToUTF16("video/*");
24 string16 test_title = ASCIIToUTF16("Title");
24 25
25 class WebIntentsTableTest : public testing::Test { 26 class WebIntentsTableTest : public testing::Test {
26 protected: 27 protected:
27 virtual void SetUp() { 28 virtual void SetUp() {
28 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
29 ASSERT_EQ(sql::INIT_OK, 30 ASSERT_EQ(sql::INIT_OK,
30 db_.Init(temp_dir_.path().AppendASCII("TestWebDatabase.db"))); 31 db_.Init(temp_dir_.path().AppendASCII("TestWebDatabase.db")));
31 } 32 }
32 33
33 WebIntentsTable* IntentsTable() { 34 WebIntentsTable* IntentsTable() {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 96 }
96 97
97 // Test we support getting all intents independent of action. 98 // Test we support getting all intents independent of action.
98 TEST_F(WebIntentsTableTest, GetAllIntents) { 99 TEST_F(WebIntentsTableTest, GetAllIntents) {
99 std::vector<WebIntentData> intents; 100 std::vector<WebIntentData> intents;
100 101
101 WebIntentData intent; 102 WebIntentData intent;
102 intent.service_url = test_url; 103 intent.service_url = test_url;
103 intent.action = test_action; 104 intent.action = test_action;
104 intent.type = mime_image; 105 intent.type = mime_image;
106 intent.title = test_title;
105 EXPECT_TRUE(IntentsTable()->SetWebIntent(intent)); 107 EXPECT_TRUE(IntentsTable()->SetWebIntent(intent));
106 108
107 intent.action = test_action_2; 109 intent.action = test_action_2;
108 EXPECT_TRUE(IntentsTable()->SetWebIntent(intent)); 110 EXPECT_TRUE(IntentsTable()->SetWebIntent(intent));
109 111
110 // Recover stored intents from DB. 112 // Recover stored intents from DB.
111 EXPECT_TRUE(IntentsTable()->GetAllWebIntents(&intents)); 113 EXPECT_TRUE(IntentsTable()->GetAllWebIntents(&intents));
112 ASSERT_EQ(2U, intents.size()); 114 ASSERT_EQ(2U, intents.size());
113 115
114 // WebIntentsTable does not guarantee order, so ensure order here. 116 // WebIntentsTable does not guarantee order, so ensure order here.
115 if (intents[0].type == test_action_2) 117 if (intents[0].type == test_action_2)
116 std::swap(intents[0], intents[1]); 118 std::swap(intents[0], intents[1]);
117 119
118 EXPECT_EQ(intent, intents[1]); 120 EXPECT_EQ(intent, intents[1]);
119 121
120 intent.action = test_action; 122 intent.action = test_action;
121 EXPECT_EQ(intent, intents[0]); 123 EXPECT_EQ(intent, intents[0]);
122 } 124 }
123 } // namespace 125 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698