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

Side by Side Diff: chrome/browser/sync/glue/extensions_activity_monitor_unittest.cc

Issue 340643002: Use TestBrowserThreadBundle instead of TestBrowserThread in sync code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/sync/glue/extensions_activity_monitor.h" 5 #include "chrome/browser/sync/glue/extensions_activity_monitor.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" 12 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h"
13 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/test/test_browser_thread.h" 15 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "extensions/common/extension.h" 16 #include "extensions/common/extension.h"
17 #include "extensions/common/manifest_constants.h" 17 #include "extensions/common/manifest_constants.h"
18 #include "sync/util/extensions_activity.h" 18 #include "sync/util/extensions_activity.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 using extensions::Extension; 21 using extensions::Extension;
22 22
23 namespace browser_sync { 23 namespace browser_sync {
24 24
25 namespace { 25 namespace {
26 26
27 using content::BrowserThread;
28 namespace keys = extensions::manifest_keys; 27 namespace keys = extensions::manifest_keys;
29 28
30 // Create and return an extension with the given path. 29 // Create and return an extension with the given path.
31 scoped_refptr<Extension> MakeExtension(const std::string& name) { 30 scoped_refptr<Extension> MakeExtension(const std::string& name) {
32 base::FilePath path; 31 base::FilePath path;
33 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); 32 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
34 path = path.AppendASCII(name); 33 path = path.AppendASCII(name);
35 34
36 base::DictionaryValue value; 35 base::DictionaryValue value;
37 value.SetString(keys::kVersion, "1.0.0.0"); 36 value.SetString(keys::kVersion, "1.0.0.0");
(...skipping 18 matching lines...) Expand all
56 chrome::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED, 55 chrome::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED,
57 content::Source<Extension>(extension.get()), 56 content::Source<Extension>(extension.get()),
58 content::Details<const extensions::BookmarksFunction>( 57 content::Details<const extensions::BookmarksFunction>(
59 bookmarks_function.get())); 58 bookmarks_function.get()));
60 } 59 }
61 } 60 }
62 61
63 class SyncChromeExtensionsActivityMonitorTest : public testing::Test { 62 class SyncChromeExtensionsActivityMonitorTest : public testing::Test {
64 public: 63 public:
65 SyncChromeExtensionsActivityMonitorTest() 64 SyncChromeExtensionsActivityMonitorTest()
66 : ui_thread_(BrowserThread::UI, &ui_loop_), 65 : thread_bundle_(content::TestBrowserThreadBundle::DEFAULT),
67 extension1_(MakeExtension("extension1")), 66 extension1_(MakeExtension("extension1")),
68 extension2_(MakeExtension("extension2")), 67 extension2_(MakeExtension("extension2")),
69 id1_(extension1_->id()), 68 id1_(extension1_->id()),
70 id2_(extension2_->id()) {} 69 id2_(extension2_->id()) {}
71 virtual ~SyncChromeExtensionsActivityMonitorTest() {} 70 virtual ~SyncChromeExtensionsActivityMonitorTest() {}
72 71
73 private: 72 private:
74 base::MessageLoop ui_loop_; 73 content::TestBrowserThreadBundle thread_bundle_;
75 content::TestBrowserThread ui_thread_;
76 74
77 protected: 75 protected:
78 ExtensionsActivityMonitor monitor_; 76 ExtensionsActivityMonitor monitor_;
79 scoped_refptr<Extension> extension1_; 77 scoped_refptr<Extension> extension1_;
80 scoped_refptr<Extension> extension2_; 78 scoped_refptr<Extension> extension2_;
81 // IDs of |extension{1,2}_|. 79 // IDs of |extension{1,2}_|.
82 const std::string& id1_; 80 const std::string& id1_;
83 const std::string& id2_; 81 const std::string& id2_;
84 }; 82 };
85 83
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 FireBookmarksApiEvent<extensions::BookmarksCreateFunction>(extension1_, 3); 164 FireBookmarksApiEvent<extensions::BookmarksCreateFunction>(extension1_, 3);
167 monitor_.GetExtensionsActivity()->GetAndClearRecords(&results); 165 monitor_.GetExtensionsActivity()->GetAndClearRecords(&results);
168 166
169 EXPECT_EQ(1U, results.size()); 167 EXPECT_EQ(1U, results.size());
170 EXPECT_EQ(3U, results[id1_].bookmark_write_count); 168 EXPECT_EQ(3U, results[id1_].bookmark_write_count);
171 } 169 }
172 170
173 } // namespace 171 } // namespace
174 172
175 } // namespace browser_sync 173 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698