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

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

Issue 8477005: Add policies to specify an enterprise web store. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasse. Created 9 years, 1 month 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/json/json_value_serializer.h" 6 #include "base/json/json_value_serializer.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/scoped_temp_dir.h" 8 #include "base/scoped_temp_dir.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/test_extension_service.h"
10 #include "chrome/browser/intents/web_intents_registry.h" 11 #include "chrome/browser/intents/web_intents_registry.h"
11 #include "chrome/browser/webdata/web_data_service.h" 12 #include "chrome/browser/webdata/web_data_service.h"
12 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
13 #include "content/test/test_browser_thread.h" 14 #include "content/test/test_browser_thread.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using content::BrowserThread; 18 using content::BrowserThread;
18 using webkit_glue::WebIntentServiceData; 19 using webkit_glue::WebIntentServiceData;
19 20
20 class MockExtensionService: public ExtensionServiceInterface { 21 class MockExtensionService: public TestExtensionService {
21 public: 22 public:
22 virtual ~MockExtensionService() {} 23 virtual ~MockExtensionService() {}
23 MOCK_CONST_METHOD0(extensions, const ExtensionList*()); 24 MOCK_CONST_METHOD0(extensions, const ExtensionList*());
24 MOCK_METHOD0(pending_extension_manager, PendingExtensionManager*());
25 MOCK_METHOD4(UpdateExtension, bool(const std::string& id,
26 const FilePath& path,
27 const GURL& download_url,
28 CrxInstaller** out_crx_installer));
29 MOCK_CONST_METHOD2(GetExtensionById,
30 const Extension*(const std::string& id,
31 bool include_disabled));
32 MOCK_CONST_METHOD1(GetInstalledExtension,
33 const Extension*(const std::string& id));
34 MOCK_CONST_METHOD1(IsExtensionEnabled,bool(const std::string& extension_id));
35 MOCK_CONST_METHOD1(IsExternalExtensionUninstalled,
36 bool(const std::string& extension_id));
37 MOCK_METHOD1(UpdateExtensionBlacklist,
38 void(const std::vector<std::string>& blacklist));
39 MOCK_METHOD0(CheckAdminBlacklist, void());;
40 MOCK_METHOD0(CheckForUpdatesSoon,void());
41
42 MOCK_METHOD3(MergeDataAndStartSyncing,
43 SyncError(syncable::ModelType type,
44 const SyncDataList& initial_sync_data,
45 SyncChangeProcessor* sync_processor));
46 MOCK_METHOD1(StopSyncing, void(syncable::ModelType type));
47 MOCK_CONST_METHOD1(GetAllSyncData, SyncDataList(syncable::ModelType type));
48 MOCK_METHOD2(ProcessSyncChanges,
49 SyncError(const tracked_objects::Location& from_here,
50 const SyncChangeList& change_list));
51 }; 25 };
52 26
53 // TODO(groby): Unify loading functions with extension_manifest_unittest code. 27 // TODO(groby): Unify loading functions with extension_manifest_unittest code.
54 DictionaryValue* LoadManifestFile(const std::string& filename, 28 DictionaryValue* LoadManifestFile(const std::string& filename,
55 std::string* error) { 29 std::string* error) {
56 FilePath path; 30 FilePath path;
57 PathService::Get(chrome::DIR_TEST_DATA, &path); 31 PathService::Get(chrome::DIR_TEST_DATA, &path);
58 path = path.AppendASCII("extensions") 32 path = path.AppendASCII("extensions")
59 .AppendASCII("manifest_tests") 33 .AppendASCII("manifest_tests")
60 .AppendASCII(filename.c_str()); 34 .AppendASCII(filename.c_str());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 db_thread_(BrowserThread::DB) {} 88 db_thread_(BrowserThread::DB) {}
115 89
116 protected: 90 protected:
117 virtual void SetUp() { 91 virtual void SetUp() {
118 CommandLine::ForCurrentProcess()->AppendSwitch("--enable-web-intents"); 92 CommandLine::ForCurrentProcess()->AppendSwitch("--enable-web-intents");
119 93
120 db_thread_.Start(); 94 db_thread_.Start();
121 wds_ = new WebDataService(); 95 wds_ = new WebDataService();
122 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 96 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
123 wds_->Init(temp_dir_.path()); 97 wds_->Init(temp_dir_.path());
124 registry_.Initialize(wds_, &extensionService_); 98 registry_.Initialize(wds_, &extension_service_);
125 EXPECT_CALL(extensionService_, extensions()). 99 EXPECT_CALL(extension_service_, extensions()).
126 WillRepeatedly(testing::Return(&extensions_)); 100 WillRepeatedly(testing::Return(&extensions_));
127 } 101 }
128 102
129 virtual void TearDown() { 103 virtual void TearDown() {
130 if (wds_.get()) 104 if (wds_.get())
131 wds_->Shutdown(); 105 wds_->Shutdown();
132 106
133 db_thread_.Stop(); 107 db_thread_.Stop();
134 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); 108 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask);
135 MessageLoop::current()->Run(); 109 MessageLoop::current()->Run();
136 } 110 }
137 111
138 MessageLoopForUI message_loop_; 112 MessageLoopForUI message_loop_;
139 content::TestBrowserThread ui_thread_; 113 content::TestBrowserThread ui_thread_;
140 content::TestBrowserThread db_thread_; 114 content::TestBrowserThread db_thread_;
141 scoped_refptr<WebDataService> wds_; 115 scoped_refptr<WebDataService> wds_;
142 MockExtensionService extensionService_; 116 MockExtensionService extension_service_;
143 ExtensionList extensions_; 117 ExtensionList extensions_;
144 WebIntentsRegistry registry_; 118 WebIntentsRegistry registry_;
145 ScopedTempDir temp_dir_; 119 ScopedTempDir temp_dir_;
146 }; 120 };
147 121
148 // Simple consumer for WebIntentsRegistry notifications. Stores result data and 122 // Simple consumer for WebIntentsRegistry notifications. Stores result data and
149 // terminates UI thread when callback is invoked. 123 // terminates UI thread when callback is invoked.
150 class TestConsumer: public WebIntentsRegistry::Consumer { 124 class TestConsumer: public WebIntentsRegistry::Consumer {
151 public: 125 public:
152 virtual void OnIntentsQueryDone( 126 virtual void OnIntentsQueryDone(
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 consumer.expected_id_ = registry_.GetIntentProviders( 323 consumer.expected_id_ = registry_.GetIntentProviders(
350 ASCIIToUTF16("http://webintents.org/share"), 324 ASCIIToUTF16("http://webintents.org/share"),
351 ASCIIToUTF16("*"), &consumer); 325 ASCIIToUTF16("*"), &consumer);
352 consumer.WaitForData(); 326 consumer.WaitForData();
353 ASSERT_EQ(4U, consumer.services_.size()); 327 ASSERT_EQ(4U, consumer.services_.size());
354 EXPECT_EQ(services[0], consumer.services_[0]); 328 EXPECT_EQ(services[0], consumer.services_[0]);
355 EXPECT_EQ(services[1], consumer.services_[1]); 329 EXPECT_EQ(services[1], consumer.services_[1]);
356 EXPECT_EQ(services[2], consumer.services_[2]); 330 EXPECT_EQ(services[2], consumer.services_[2]);
357 EXPECT_EQ(services[3], consumer.services_[3]); 331 EXPECT_EQ(services[3], consumer.services_[3]);
358 } 332 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698