| OLD | NEW |
| 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" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 // Fire a bookmarks API event from the given extension the given | 46 // Fire a bookmarks API event from the given extension the given |
| 47 // number of times. | 47 // number of times. |
| 48 template <class T> | 48 template <class T> |
| 49 void FireBookmarksApiEvent( | 49 void FireBookmarksApiEvent( |
| 50 const scoped_refptr<Extension>& extension, int repeats) { | 50 const scoped_refptr<Extension>& extension, int repeats) { |
| 51 scoped_refptr<T> bookmarks_function(new T()); | 51 scoped_refptr<T> bookmarks_function(new T()); |
| 52 bookmarks_function->set_name(T::function_name()); | 52 bookmarks_function->set_name(T::function_name()); |
| 53 for (int i = 0; i < repeats; i++) { | 53 for (int i = 0; i < repeats; i++) { |
| 54 content::NotificationService::current()->Notify( | 54 content::NotificationService::current()->Notify( |
| 55 chrome::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED, | 55 extensions::NOTIFICATION_EXTENSION_BOOKMARKS_API_INVOKED, |
| 56 content::Source<Extension>(extension.get()), | 56 content::Source<Extension>(extension.get()), |
| 57 content::Details<const extensions::BookmarksFunction>( | 57 content::Details<const extensions::BookmarksFunction>( |
| 58 bookmarks_function.get())); | 58 bookmarks_function.get())); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 class SyncChromeExtensionsActivityMonitorTest : public testing::Test { | 62 class SyncChromeExtensionsActivityMonitorTest : public testing::Test { |
| 63 public: | 63 public: |
| 64 SyncChromeExtensionsActivityMonitorTest() | 64 SyncChromeExtensionsActivityMonitorTest() |
| 65 : thread_bundle_(content::TestBrowserThreadBundle::DEFAULT), | 65 : thread_bundle_(content::TestBrowserThreadBundle::DEFAULT), |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 FireBookmarksApiEvent<extensions::BookmarksCreateFunction>(extension1_, 3); | 164 FireBookmarksApiEvent<extensions::BookmarksCreateFunction>(extension1_, 3); |
| 165 monitor_.GetExtensionsActivity()->GetAndClearRecords(&results); | 165 monitor_.GetExtensionsActivity()->GetAndClearRecords(&results); |
| 166 | 166 |
| 167 EXPECT_EQ(1U, results.size()); | 167 EXPECT_EQ(1U, results.size()); |
| 168 EXPECT_EQ(3U, results[id1_].bookmark_write_count); | 168 EXPECT_EQ(3U, results[id1_].bookmark_write_count); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace | 171 } // namespace |
| 172 | 172 |
| 173 } // namespace browser_sync | 173 } // namespace browser_sync |
| OLD | NEW |