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

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

Issue 7930002: Rename WebIntentData for backend storage to WebIntentServiceData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix class/struct decl Created 9 years, 3 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
« no previous file with comments | « chrome/browser/webdata/web_data_service.cc ('k') | chrome/browser/webdata/web_intents_table.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // Simple consumer for WebIntents data. Stores the result data and quits UI 147 // Simple consumer for WebIntents data. Stores the result data and quits UI
148 // message loop when callback is invoked. 148 // message loop when callback is invoked.
149 class WebIntentsConsumer: public WebDataServiceConsumer { 149 class WebIntentsConsumer: public WebDataServiceConsumer {
150 public: 150 public:
151 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, 151 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h,
152 const WDTypedResult* result) { 152 const WDTypedResult* result) {
153 intents.clear(); 153 intents.clear();
154 if (result) { 154 if (result) {
155 DCHECK(result->GetType() == WEB_INTENTS_RESULT); 155 DCHECK(result->GetType() == WEB_INTENTS_RESULT);
156 intents = static_cast< 156 intents = static_cast<
157 const WDResult<std::vector<WebIntentData> >*>(result)->GetValue(); 157 const WDResult<std::vector<WebIntentServiceData> >*>(result)->
158 GetValue();
158 } 159 }
159 160
160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
161 MessageLoop::current()->Quit(); 162 MessageLoop::current()->Quit();
162 } 163 }
163 164
164 // Run the current message loop. OnWebDataServiceRequestDone will invoke 165 // Run the current message loop. OnWebDataServiceRequestDone will invoke
165 // MessageLoop::Quit on completion, so this call will finish at that point. 166 // MessageLoop::Quit on completion, so this call will finish at that point.
166 static void WaitUntilCalled() { 167 static void WaitUntilCalled() {
167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
168 MessageLoop::current()->Run(); 169 MessageLoop::current()->Run();
169 } 170 }
170 171
171 std::vector<WebIntentData> intents; // Result data from completion callback. 172 // Result data from completion callback.
173 std::vector<WebIntentServiceData> intents;
172 }; 174 };
173 175
174 TEST_F(WebDataServiceAutofillTest, FormFillAdd) { 176 TEST_F(WebDataServiceAutofillTest, FormFillAdd) {
175 const AutofillChange expected_changes[] = { 177 const AutofillChange expected_changes[] = {
176 AutofillChange(AutofillChange::ADD, AutofillKey(name1_, value1_)), 178 AutofillChange(AutofillChange::ADD, AutofillKey(name1_, value1_)),
177 AutofillChange(AutofillChange::ADD, AutofillKey(name2_, value2_)) 179 AutofillChange(AutofillChange::ADD, AutofillKey(name2_, value2_))
178 }; 180 };
179 181
180 // This will verify that the correct notification is triggered, 182 // This will verify that the correct notification is triggered,
181 // passing the correct list of autofill keys in the details. 183 // passing the correct list of autofill keys in the details.
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 ASSERT_EQ(0U, card_consumer2.result().size()); 596 ASSERT_EQ(0U, card_consumer2.result().size());
595 } 597 }
596 598
597 TEST_F(WebDataServiceTest, WebIntents) { 599 TEST_F(WebDataServiceTest, WebIntents) {
598 WebIntentsConsumer consumer; 600 WebIntentsConsumer consumer;
599 601
600 wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer); 602 wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer);
601 WebIntentsConsumer::WaitUntilCalled(); 603 WebIntentsConsumer::WaitUntilCalled();
602 EXPECT_EQ(0U, consumer.intents.size()); 604 EXPECT_EQ(0U, consumer.intents.size());
603 605
604 WebIntentData intent; 606 WebIntentServiceData service;
605 intent.service_url = GURL("http://google.com"); 607 service.service_url = GURL("http://google.com");
606 intent.action = ASCIIToUTF16("share"); 608 service.action = ASCIIToUTF16("share");
607 intent.type = ASCIIToUTF16("image/*"); 609 service.type = ASCIIToUTF16("image/*");
608 wds_->AddWebIntent(intent); 610 wds_->AddWebIntent(service);
609 611
610 intent.type = ASCIIToUTF16("video/*"); 612 service.type = ASCIIToUTF16("video/*");
611 wds_->AddWebIntent(intent); 613 wds_->AddWebIntent(service);
612 614
613 wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer); 615 wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer);
614 WebIntentsConsumer::WaitUntilCalled(); 616 WebIntentsConsumer::WaitUntilCalled();
615 ASSERT_EQ(2U, consumer.intents.size()); 617 ASSERT_EQ(2U, consumer.intents.size());
616 618
617 if (consumer.intents[0].type != ASCIIToUTF16("image/*")) 619 if (consumer.intents[0].type != ASCIIToUTF16("image/*"))
618 std::swap(consumer.intents[0],consumer.intents[1]); 620 std::swap(consumer.intents[0],consumer.intents[1]);
619 621
620 EXPECT_EQ(intent.service_url, consumer.intents[0].service_url); 622 EXPECT_EQ(service.service_url, consumer.intents[0].service_url);
621 EXPECT_EQ(intent.action, consumer.intents[0].action); 623 EXPECT_EQ(service.action, consumer.intents[0].action);
622 EXPECT_EQ(ASCIIToUTF16("image/*"), consumer.intents[0].type); 624 EXPECT_EQ(ASCIIToUTF16("image/*"), consumer.intents[0].type);
623 EXPECT_EQ(intent.service_url, consumer.intents[1].service_url); 625 EXPECT_EQ(service.service_url, consumer.intents[1].service_url);
624 EXPECT_EQ(intent.action, consumer.intents[1].action); 626 EXPECT_EQ(service.action, consumer.intents[1].action);
625 EXPECT_EQ(intent.type, consumer.intents[1].type); 627 EXPECT_EQ(service.type, consumer.intents[1].type);
626 628
627 intent.type = ASCIIToUTF16("image/*"); 629 service.type = ASCIIToUTF16("image/*");
628 wds_->RemoveWebIntent(intent); 630 wds_->RemoveWebIntent(service);
629 631
630 wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer); 632 wds_->GetWebIntents(ASCIIToUTF16("share"), &consumer);
631 WebIntentsConsumer::WaitUntilCalled(); 633 WebIntentsConsumer::WaitUntilCalled();
632 ASSERT_EQ(1U, consumer.intents.size()); 634 ASSERT_EQ(1U, consumer.intents.size());
633 635
634 intent.type = ASCIIToUTF16("video/*"); 636 service.type = ASCIIToUTF16("video/*");
635 EXPECT_EQ(intent.service_url, consumer.intents[0].service_url); 637 EXPECT_EQ(service.service_url, consumer.intents[0].service_url);
636 EXPECT_EQ(intent.action, consumer.intents[0].action); 638 EXPECT_EQ(service.action, consumer.intents[0].action);
637 EXPECT_EQ(intent.type, consumer.intents[0].type); 639 EXPECT_EQ(service.type, consumer.intents[0].type);
638 } 640 }
639 641
640 TEST_F(WebDataServiceTest, WebIntentsGetAll) { 642 TEST_F(WebDataServiceTest, WebIntentsGetAll) {
641 WebIntentsConsumer consumer; 643 WebIntentsConsumer consumer;
642 644
643 WebIntentData intent; 645 WebIntentServiceData service;
644 intent.service_url = GURL("http://google.com"); 646 service.service_url = GURL("http://google.com");
645 intent.action = ASCIIToUTF16("share"); 647 service.action = ASCIIToUTF16("share");
646 intent.type = ASCIIToUTF16("image/*"); 648 service.type = ASCIIToUTF16("image/*");
647 wds_->AddWebIntent(intent); 649 wds_->AddWebIntent(service);
648 650
649 intent.action = ASCIIToUTF16("edit"); 651 service.action = ASCIIToUTF16("edit");
650 wds_->AddWebIntent(intent); 652 wds_->AddWebIntent(service);
651 653
652 wds_->GetAllWebIntents(&consumer); 654 wds_->GetAllWebIntents(&consumer);
653 WebIntentsConsumer::WaitUntilCalled(); 655 WebIntentsConsumer::WaitUntilCalled();
654 ASSERT_EQ(2U, consumer.intents.size()); 656 ASSERT_EQ(2U, consumer.intents.size());
655 657
656 if (consumer.intents[0].action != ASCIIToUTF16("edit")) 658 if (consumer.intents[0].action != ASCIIToUTF16("edit"))
657 std::swap(consumer.intents[0],consumer.intents[1]); 659 std::swap(consumer.intents[0],consumer.intents[1]);
658 660
659 EXPECT_EQ(intent, consumer.intents[0]); 661 EXPECT_EQ(service, consumer.intents[0]);
660 intent.action = ASCIIToUTF16("share"); 662 service.action = ASCIIToUTF16("share");
661 EXPECT_EQ(intent, consumer.intents[1]); 663 EXPECT_EQ(service, consumer.intents[1]);
662 } 664 }
663
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_service.cc ('k') | chrome/browser/webdata/web_intents_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698