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

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

Issue 8144013: Add a check to the registry before the intent infobar is shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 9 years, 2 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 #include "webkit/glue/web_intent_service_data.h" 16 #include "webkit/glue/web_intent_service_data.h"
17 17
18 namespace { 18 namespace {
19 19
20 GURL test_url("http://google.com/"); 20 GURL test_url("http://google.com/");
21 GURL test_url_fake("http://fakegoogle.com/");
21 string16 test_action = ASCIIToUTF16("http://webintents.org/intents/share"); 22 string16 test_action = ASCIIToUTF16("http://webintents.org/intents/share");
22 string16 test_action_2 = ASCIIToUTF16("http://webintents.org/intents/view"); 23 string16 test_action_2 = ASCIIToUTF16("http://webintents.org/intents/view");
23 string16 test_title = ASCIIToUTF16("Test WebIntent"); 24 string16 test_title = ASCIIToUTF16("Test WebIntent");
24 string16 test_title_2 = ASCIIToUTF16("Test WebIntent #2"); 25 string16 test_title_2 = ASCIIToUTF16("Test WebIntent #2");
25 string16 mime_image = ASCIIToUTF16("image/*"); 26 string16 mime_image = ASCIIToUTF16("image/*");
26 string16 mime_video = ASCIIToUTF16("video/*"); 27 string16 mime_video = ASCIIToUTF16("video/*");
27 28
28 WebIntentServiceData MakeIntent(const GURL& url, const string16& action, 29 WebIntentServiceData MakeIntent(const GURL& url, const string16& action,
29 const string16& type, const string16& title) { 30 const string16& type, const string16& title) {
30 WebIntentServiceData service; 31 WebIntentServiceData service;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 std::vector<WebIntentServiceData> intents; 148 std::vector<WebIntentServiceData> intents;
148 EXPECT_TRUE(IntentsTable()->GetAllWebIntents(&intents)); 149 EXPECT_TRUE(IntentsTable()->GetAllWebIntents(&intents));
149 ASSERT_EQ(2U, intents.size()); 150 ASSERT_EQ(2U, intents.size());
150 151
151 if (intents[0].disposition == WebIntentServiceData::DISPOSITION_WINDOW) 152 if (intents[0].disposition == WebIntentServiceData::DISPOSITION_WINDOW)
152 std::swap(intents[0], intents[1]); 153 std::swap(intents[0], intents[1]);
153 154
154 EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, intents[0].disposition); 155 EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, intents[0].disposition);
155 EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, intents[1].disposition); 156 EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, intents[1].disposition);
156 } 157 }
158
159 TEST_F(WebIntentsTableTest, GetByURL) {
160 WebIntentServiceData intent = MakeIntent(test_url, test_action, mime_image,
161 test_title);
162 ASSERT_TRUE(IntentsTable()->SetWebIntent(intent));
163
164 std::vector<WebIntentServiceData> intents;
165 EXPECT_TRUE(IntentsTable()->GetWebIntentsForURL(
166 test_action, UTF8ToUTF16(test_url.spec()), &intents));
167 ASSERT_EQ(1U, intents.size());
168 EXPECT_EQ(intent, intents[0]);
169
170 intents.clear();
171 EXPECT_TRUE(IntentsTable()->GetWebIntentsForURL(
172 test_action, UTF8ToUTF16(test_url_fake.spec()), &intents));
173 EXPECT_EQ(0U, intents.size());
174
175 EXPECT_TRUE(IntentsTable()->GetWebIntentsForURL(
176 test_action_2, UTF8ToUTF16(test_url.spec()), &intents));
177 EXPECT_EQ(0U, intents.size());
178 }
179
157 } // namespace 180 } // namespace
OLDNEW
« chrome/browser/webdata/web_intents_table.cc ('K') | « chrome/browser/webdata/web_intents_table.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698