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

Side by Side Diff: chrome/browser/intents/web_intents_registry_unittest.cc

Issue 10006037: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reverted one unneeded change Created 8 years, 8 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) 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/json/json_file_value_serializer.h" 6 #include "base/json/json_file_value_serializer.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/synchronization/waitable_event.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/extensions/test_extension_service.h" 12 #include "chrome/browser/extensions/test_extension_service.h"
12 #include "chrome/browser/intents/default_web_intent_service.h" 13 #include "chrome/browser/intents/default_web_intent_service.h"
13 #include "chrome/browser/intents/web_intents_registry.h" 14 #include "chrome/browser/intents/web_intents_registry.h"
14 #include "chrome/browser/webdata/web_data_service.h" 15 #include "chrome/browser/webdata/web_data_service.h"
15 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
16 #include "chrome/common/extensions/extension_set.h" 17 #include "chrome/common/extensions/extension_set.h"
17 #include "content/test/test_browser_thread.h" 18 #include "content/test/test_browser_thread.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 wds_->Init(temp_dir_.path()); 95 wds_->Init(temp_dir_.path());
95 registry_.Initialize(wds_, &extension_service_); 96 registry_.Initialize(wds_, &extension_service_);
96 EXPECT_CALL(extension_service_, extensions()). 97 EXPECT_CALL(extension_service_, extensions()).
97 WillRepeatedly(testing::Return(&extensions_)); 98 WillRepeatedly(testing::Return(&extensions_));
98 EXPECT_CALL(extension_service_, GetExtensionById(testing::_, testing::_)). 99 EXPECT_CALL(extension_service_, GetExtensionById(testing::_, testing::_)).
99 WillRepeatedly( 100 WillRepeatedly(
100 testing::Invoke(this, &WebIntentsRegistryTest::GetExtensionById)); 101 testing::Invoke(this, &WebIntentsRegistryTest::GetExtensionById));
101 } 102 }
102 103
103 virtual void TearDown() { 104 virtual void TearDown() {
104 if (wds_.get()) 105 wds_ = NULL;
105 wds_->Shutdown();
106 106
107 // Schedule another task on the DB thread to notify us that it's safe to
108 // carry on with the test.
109 base::WaitableEvent done(false, false);
110 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
111 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
112 done.Wait();
107 db_thread_.Stop(); 113 db_thread_.Stop();
108 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 114 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
109 MessageLoop::current()->Run(); 115 MessageLoop::current()->Run();
110 } 116 }
111 117
112 const Extension* GetExtensionById(const std::string& extension_id, 118 const Extension* GetExtensionById(const std::string& extension_id,
113 testing::Unused) { 119 testing::Unused) {
114 for (ExtensionSet::const_iterator iter = extensions_.begin(); 120 for (ExtensionSet::const_iterator iter = extensions_.begin();
115 iter != extensions_.end(); ++iter) { 121 iter != extensions_.end(); ++iter) {
116 if ((*iter)->id() == extension_id) 122 if ((*iter)->id() == extension_id)
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 registry_.RegisterIntentService(services[1]); 513 registry_.RegisterIntentService(services[1]);
508 514
509 TestConsumer consumer; 515 TestConsumer consumer;
510 consumer.expected_id_ = registry_.GetIntentServices( 516 consumer.expected_id_ = registry_.GetIntentServices(
511 ASCIIToUTF16("http://webintents.org/share"), 517 ASCIIToUTF16("http://webintents.org/share"),
512 ASCIIToUTF16("image/*"), &consumer); 518 ASCIIToUTF16("image/*"), &consumer);
513 consumer.WaitForData(); 519 consumer.WaitForData();
514 ASSERT_EQ(1U, consumer.services_.size()); 520 ASSERT_EQ(1U, consumer.services_.size());
515 EXPECT_EQ(ASCIIToUTF16("image/png,image/jpg"), consumer.services_[0].type); 521 EXPECT_EQ(ASCIIToUTF16("image/png,image/jpg"), consumer.services_[0].type);
516 } 522 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698