diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-05 17:56:39 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-05 17:56:39 +0000 |
commit | 3339229822e7af543067d5267d3b9795bd6e4485 (patch) | |
tree | 76d893bdea7b1895303aad3c265cbb0946c5154f | |
parent | 8cb02edc531a8334b2bd48087a91b4cbdf40c2d7 (diff) | |
download | chromium_src-3339229822e7af543067d5267d3b9795bd6e4485.zip chromium_src-3339229822e7af543067d5267d3b9795bd6e4485.tar.gz chromium_src-3339229822e7af543067d5267d3b9795bd6e4485.tar.bz2 |
Move lots of GMock stuff out of line.
Nico did some treemapping of our build time on Mac, and (surprise!) gmock
unittests dominated. Gmock works with several large, heavy templates, and previous patches that out of line the ctors/dtors have significantly sped up compilation (e.g.GLMock) and have reduced thrashing.
Nico says I should plug this again: http://www.chromium.org/developers/coding-style/cpp-dos-and-donts
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6056008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70516 0039d316-1c4b-4281-b951-d872f2087c98
39 files changed, 431 insertions, 149 deletions
diff --git a/chrome/browser/policy/device_management_backend_mock.cc b/chrome/browser/policy/device_management_backend_mock.cc new file mode 100644 index 0000000..b8dcf5f --- /dev/null +++ b/chrome/browser/policy/device_management_backend_mock.cc @@ -0,0 +1,21 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/policy/device_management_backend_mock.h" + +namespace policy { + +DeviceRegisterResponseDelegateMock::DeviceRegisterResponseDelegateMock() {} + +DeviceRegisterResponseDelegateMock::~DeviceRegisterResponseDelegateMock() {} + +DeviceUnregisterResponseDelegateMock::DeviceUnregisterResponseDelegateMock() {} + +DeviceUnregisterResponseDelegateMock::~DeviceUnregisterResponseDelegateMock() {} + +DevicePolicyResponseDelegateMock::DevicePolicyResponseDelegateMock() {} + +DevicePolicyResponseDelegateMock::~DevicePolicyResponseDelegateMock() {} + +} // namespace policy diff --git a/chrome/browser/policy/device_management_backend_mock.h b/chrome/browser/policy/device_management_backend_mock.h index 9e082a6..0533efc 100644 --- a/chrome/browser/policy/device_management_backend_mock.h +++ b/chrome/browser/policy/device_management_backend_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,6 +15,9 @@ namespace policy { class DeviceRegisterResponseDelegateMock : public DeviceManagementBackend::DeviceRegisterResponseDelegate { public: + DeviceRegisterResponseDelegateMock(); + virtual ~DeviceRegisterResponseDelegateMock(); + MOCK_METHOD1(HandleRegisterResponse, void(const em::DeviceRegisterResponse&)); MOCK_METHOD1(OnError, void(DeviceManagementBackend::ErrorCode error)); }; @@ -22,6 +25,9 @@ class DeviceRegisterResponseDelegateMock class DeviceUnregisterResponseDelegateMock : public DeviceManagementBackend::DeviceUnregisterResponseDelegate { public: + DeviceUnregisterResponseDelegateMock(); + virtual ~DeviceUnregisterResponseDelegateMock(); + MOCK_METHOD1(HandleUnregisterResponse, void(const em::DeviceUnregisterResponse&)); MOCK_METHOD1(OnError, void(DeviceManagementBackend::ErrorCode error)); @@ -30,6 +36,9 @@ class DeviceUnregisterResponseDelegateMock class DevicePolicyResponseDelegateMock : public DeviceManagementBackend::DevicePolicyResponseDelegate { public: + DevicePolicyResponseDelegateMock(); + virtual ~DevicePolicyResponseDelegateMock(); + MOCK_METHOD1(HandlePolicyResponse, void(const em::DevicePolicyResponse&)); MOCK_METHOD1(OnError, void(DeviceManagementBackend::ErrorCode error)); }; diff --git a/chrome/browser/prefs/pref_observer_mock.cc b/chrome/browser/prefs/pref_observer_mock.cc new file mode 100644 index 0000000..a41ed5c --- /dev/null +++ b/chrome/browser/prefs/pref_observer_mock.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/prefs/pref_observer_mock.h" + +PrefObserverMock::PrefObserverMock() {} + +PrefObserverMock::~PrefObserverMock() {} + +void PrefObserverMock::Expect(const PrefService* prefs, + const std::string& pref_name, + const Value* value) { + EXPECT_CALL(*this, Observe(NotificationType(NotificationType::PREF_CHANGED), + Source<PrefService>(prefs), + Property(&Details<std::string>::ptr, + Pointee(pref_name)))) + .With(PrefValueMatches(prefs, pref_name, value)); +} diff --git a/chrome/browser/prefs/pref_observer_mock.h b/chrome/browser/prefs/pref_observer_mock.h index f339841..0c651ca 100644 --- a/chrome/browser/prefs/pref_observer_mock.h +++ b/chrome/browser/prefs/pref_observer_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -39,8 +39,8 @@ MATCHER_P3(PrefValueMatches, prefs, pref_name, value, "") { // A mock for testing preference notifications and easy setup of expectations. class PrefObserverMock : public NotificationObserver { public: - PrefObserverMock() {} - virtual ~PrefObserverMock() {} + PrefObserverMock(); + virtual ~PrefObserverMock(); MOCK_METHOD3(Observe, void(NotificationType type, const NotificationSource& source, @@ -48,13 +48,7 @@ class PrefObserverMock : public NotificationObserver { void Expect(const PrefService* prefs, const std::string& pref_name, - const Value* value) { - EXPECT_CALL(*this, Observe(NotificationType(NotificationType::PREF_CHANGED), - Source<PrefService>(prefs), - Property(&Details<std::string>::ptr, - Pointee(pref_name)))) - .With(PrefValueMatches(prefs, pref_name, value)); - } + const Value* value); }; #endif // CHROME_BROWSER_PREFS_PREF_OBSERVER_MOCK_H_ diff --git a/chrome/browser/prefs/pref_service_mock_builder.cc b/chrome/browser/prefs/pref_service_mock_builder.cc index 005b700..b02a334 100644 --- a/chrome/browser/prefs/pref_service_mock_builder.cc +++ b/chrome/browser/prefs/pref_service_mock_builder.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,6 +15,8 @@ PrefServiceMockBuilder::PrefServiceMockBuilder() : user_prefs_(new TestingPrefStore) { } +PrefServiceMockBuilder::~PrefServiceMockBuilder() {} + PrefServiceMockBuilder& PrefServiceMockBuilder::WithManagedPlatformPrefs(PrefStore* store) { managed_platform_prefs_.reset(store); diff --git a/chrome/browser/prefs/pref_service_mock_builder.h b/chrome/browser/prefs/pref_service_mock_builder.h index b8e32755..9cc4fcc 100644 --- a/chrome/browser/prefs/pref_service_mock_builder.h +++ b/chrome/browser/prefs/pref_service_mock_builder.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,6 +24,7 @@ class ConfigurationPolicyProvider; class PrefServiceMockBuilder { public: PrefServiceMockBuilder(); + ~PrefServiceMockBuilder(); // Functions for setting the various parameters of the PrefService to build. // These take ownership of the |store| parameter. diff --git a/chrome/browser/sync/engine/read_node_mock.h b/chrome/browser/sync/engine/read_node_mock.h index f13eddd..564f01d 100644 --- a/chrome/browser/sync/engine/read_node_mock.h +++ b/chrome/browser/sync/engine/read_node_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,8 +13,9 @@ class ReadNodeMock : public sync_api::ReadNode {
public:
- ReadNodeMock() { }
+ ReadNodeMock() {}
virtual ~ReadNodeMock() {}
+
MOCK_METHOD2(InitByClientTagLookup,
bool(syncable::ModelType model_type, const std::string& tag));
MOCK_CONST_METHOD0(GetAutofillProfileSpecifics,
@@ -25,5 +26,6 @@ class ReadNodeMock : public sync_api::ReadNode { MOCK_CONST_METHOD0(GetSuccessorId, int64());
MOCK_METHOD1(InitByIdLookup, bool(int64 id));
};
+
#endif // CHROME_BROWSER_SYNC_ENGINE_READ_NODE_MOCK_H_
diff --git a/chrome/browser/sync/glue/change_processor_mock.cc b/chrome/browser/sync/glue/change_processor_mock.cc new file mode 100644 index 0000000..faea86b --- /dev/null +++ b/chrome/browser/sync/glue/change_processor_mock.cc @@ -0,0 +1,13 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/sync/glue/change_processor_mock.h" + +namespace browser_sync { + +ChangeProcessorMock::ChangeProcessorMock() : ChangeProcessor(NULL) {} + +ChangeProcessorMock::~ChangeProcessorMock() {} + +} // namespace browser_sync diff --git a/chrome/browser/sync/glue/change_processor_mock.h b/chrome/browser/sync/glue/change_processor_mock.h index e138937..d74e40e 100644 --- a/chrome/browser/sync/glue/change_processor_mock.h +++ b/chrome/browser/sync/glue/change_processor_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,7 +17,8 @@ namespace browser_sync { class ChangeProcessorMock : public ChangeProcessor { public: - ChangeProcessorMock() : ChangeProcessor(NULL) {} + ChangeProcessorMock(); + virtual ~ChangeProcessorMock(); MOCK_METHOD3(ApplyChangesFromSyncModel, void(const sync_api::BaseTransaction* trans, const sync_api::SyncManager::ChangeRecord* changes, diff --git a/chrome/browser/sync/glue/data_type_controller_mock.cc b/chrome/browser/sync/glue/data_type_controller_mock.cc new file mode 100644 index 0000000..7909b86 --- /dev/null +++ b/chrome/browser/sync/glue/data_type_controller_mock.cc @@ -0,0 +1,13 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/sync/glue/data_type_controller_mock.h" + +namespace browser_sync { + +DataTypeControllerMock::DataTypeControllerMock() {} + +DataTypeControllerMock::~DataTypeControllerMock() {} + +} // namespace browser_sync diff --git a/chrome/browser/sync/glue/data_type_controller_mock.h b/chrome/browser/sync/glue/data_type_controller_mock.h index 09ec652..83d0b6b 100644 --- a/chrome/browser/sync/glue/data_type_controller_mock.h +++ b/chrome/browser/sync/glue/data_type_controller_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,6 +13,9 @@ namespace browser_sync { class DataTypeControllerMock : public DataTypeController { public: + DataTypeControllerMock(); + virtual ~DataTypeControllerMock(); + MOCK_METHOD1(Start, void(StartCallback* start_callback)); MOCK_METHOD0(Stop, void()); MOCK_METHOD0(enabled, bool()); diff --git a/chrome/browser/sync/glue/data_type_manager_mock.cc b/chrome/browser/sync/glue/data_type_manager_mock.cc new file mode 100644 index 0000000..9cc445e --- /dev/null +++ b/chrome/browser/sync/glue/data_type_manager_mock.cc @@ -0,0 +1,24 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/sync/glue/data_type_manager_mock.h" + +namespace browser_sync { + +DataTypeManagerMock::DataTypeManagerMock() + : result_(OK) { + // By default, calling Configure will send a SYNC_CONFIGURE_START + // and SYNC_CONFIGURE_DONE notification with a DataTypeManager::OK + // detail. + ON_CALL(*this, Configure(testing::_)). + WillByDefault(testing::DoAll( + NotifyFromDataTypeManager(this, + NotificationType::SYNC_CONFIGURE_START), + NotifyFromDataTypeManagerWithResult + (this, NotificationType::SYNC_CONFIGURE_DONE, &result_))); +} + +DataTypeManagerMock::~DataTypeManagerMock() {} + +} // namespace browser_sync diff --git a/chrome/browser/sync/glue/data_type_manager_mock.h b/chrome/browser/sync/glue/data_type_manager_mock.h index 2a1705a..05a3665 100644 --- a/chrome/browser/sync/glue/data_type_manager_mock.h +++ b/chrome/browser/sync/glue/data_type_manager_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -30,17 +30,8 @@ namespace browser_sync { class DataTypeManagerMock : public DataTypeManager { public: - DataTypeManagerMock() : result_(OK) { - // By default, calling Configure will send a SYNC_CONFIGURE_START - // and SYNC_CONFIGURE_DONE notification with a DataTypeManager::OK - // detail. - ON_CALL(*this, Configure(testing::_)). - WillByDefault(testing::DoAll( - NotifyFromDataTypeManager(this, - NotificationType::SYNC_CONFIGURE_START), - NotifyFromDataTypeManagerWithResult - (this, NotificationType::SYNC_CONFIGURE_DONE, &result_))); - } + DataTypeManagerMock(); + virtual ~DataTypeManagerMock(); MOCK_METHOD1(Configure, void(const TypeSet&)); MOCK_METHOD0(Stop, void()); diff --git a/chrome/browser/sync/glue/sync_backend_host_mock.cc b/chrome/browser/sync/glue/sync_backend_host_mock.cc new file mode 100644 index 0000000..fe488ad --- /dev/null +++ b/chrome/browser/sync/glue/sync_backend_host_mock.cc @@ -0,0 +1,26 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/sync/glue/sync_backend_host_mock.h" + +namespace browser_sync { + +SyncBackendHostMock::SyncBackendHostMock() { + // By default, the RequestPause and RequestResume methods will + // send the confirmation notification and return true. + ON_CALL(*this, RequestPause()). + WillByDefault(testing::DoAll(Notify(NotificationType::SYNC_PAUSED), + testing::Return(true))); + ON_CALL(*this, RequestResume()). + WillByDefault(testing::DoAll(Notify(NotificationType::SYNC_RESUMED), + testing::Return(true))); + + // By default, invoke the ready callback. + ON_CALL(*this, ConfigureDataTypes(testing::_, testing::_)). + WillByDefault(InvokeTask()); +} + +SyncBackendHostMock::~SyncBackendHostMock() {} + +} // namespace browser_sync diff --git a/chrome/browser/sync/glue/sync_backend_host_mock.h b/chrome/browser/sync/glue/sync_backend_host_mock.h index 4035f97..e133a57 100644 --- a/chrome/browser/sync/glue/sync_backend_host_mock.h +++ b/chrome/browser/sync/glue/sync_backend_host_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,20 +23,8 @@ ACTION(InvokeTask) { class SyncBackendHostMock : public SyncBackendHost { public: - SyncBackendHostMock() { - // By default, the RequestPause and RequestResume methods will - // send the confirmation notification and return true. - ON_CALL(*this, RequestPause()). - WillByDefault(testing::DoAll(Notify(NotificationType::SYNC_PAUSED), - testing::Return(true))); - ON_CALL(*this, RequestResume()). - WillByDefault(testing::DoAll(Notify(NotificationType::SYNC_RESUMED), - testing::Return(true))); - - // By default, invoke the ready callback. - ON_CALL(*this, ConfigureDataTypes(testing::_, testing::_)). - WillByDefault(InvokeTask()); - } + SyncBackendHostMock(); + virtual ~SyncBackendHostMock(); MOCK_METHOD2(ConfigureDataTypes, void(const std::set<syncable::ModelType>&, CancelableTask*)); diff --git a/chrome/browser/sync/profile_sync_factory_mock.cc b/chrome/browser/sync/profile_sync_factory_mock.cc index 68fc0456..2d92100 100644 --- a/chrome/browser/sync/profile_sync_factory_mock.cc +++ b/chrome/browser/sync/profile_sync_factory_mock.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,6 +11,8 @@ using browser_sync::ChangeProcessor; using testing::_; using testing::InvokeWithoutArgs; +ProfileSyncFactoryMock::ProfileSyncFactoryMock() {} + ProfileSyncFactoryMock::ProfileSyncFactoryMock( AssociatorInterface* bookmark_model_associator, ChangeProcessor* bookmark_change_processor) @@ -23,6 +25,8 @@ ProfileSyncFactoryMock::ProfileSyncFactoryMock( &ProfileSyncFactoryMock::MakeBookmarkSyncComponents)); } +ProfileSyncFactoryMock::~ProfileSyncFactoryMock() {} + ProfileSyncFactory::SyncComponents ProfileSyncFactoryMock::MakeBookmarkSyncComponents() { return SyncComponents(bookmark_model_associator_.release(), diff --git a/chrome/browser/sync/profile_sync_factory_mock.h b/chrome/browser/sync/profile_sync_factory_mock.h index f5210a0..a1d1a15 100644 --- a/chrome/browser/sync/profile_sync_factory_mock.h +++ b/chrome/browser/sync/profile_sync_factory_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,10 +18,11 @@ class ChangeProcessor; class ProfileSyncFactoryMock : public ProfileSyncFactory { public: - ProfileSyncFactoryMock() {} + ProfileSyncFactoryMock(); ProfileSyncFactoryMock( browser_sync::AssociatorInterface* bookmark_model_associator, browser_sync::ChangeProcessor* bookmark_change_processor); + virtual ~ProfileSyncFactoryMock(); MOCK_METHOD1(CreateProfileSyncService, ProfileSyncService*(const std::string&)); diff --git a/chrome/browser/sync/profile_sync_service_mock.cc b/chrome/browser/sync/profile_sync_service_mock.cc new file mode 100644 index 0000000..8bfdb10 --- /dev/null +++ b/chrome/browser/sync/profile_sync_service_mock.cc @@ -0,0 +1,9 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/sync/profile_sync_service_mock.h" + +ProfileSyncServiceMock::ProfileSyncServiceMock() {} + +ProfileSyncServiceMock::~ProfileSyncServiceMock() {} diff --git a/chrome/browser/sync/profile_sync_service_mock.h b/chrome/browser/sync/profile_sync_service_mock.h index a338631..32bff66 100644 --- a/chrome/browser/sync/profile_sync_service_mock.h +++ b/chrome/browser/sync/profile_sync_service_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,8 +17,8 @@ class ProfileSyncServiceMock : public ProfileSyncService { public: - ProfileSyncServiceMock() {} - virtual ~ProfileSyncServiceMock() {} + ProfileSyncServiceMock(); + virtual ~ProfileSyncServiceMock(); MOCK_METHOD0(DisableForUser, void()); MOCK_METHOD0(OnBackendInitialized, void()); diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 6b1374e..af458f6 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1,4 +1,4 @@ -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -63,6 +63,7 @@ #'browser/net/url_request_mock_http_job.h', 'browser/net/url_request_mock_net_error_job.cc', 'browser/net/url_request_mock_net_error_job.h', + 'browser/prefs/pref_observer_mock.cc', 'browser/prefs/pref_observer_mock.h', 'browser/prefs/pref_service_mock_builder.cc', 'browser/prefs/pref_service_mock_builder.h', @@ -76,11 +77,15 @@ 'browser/renderer_host/test/test_render_view_host.h', 'browser/tab_contents/test_tab_contents.cc', 'browser/tab_contents/test_tab_contents.h', + 'browser/sync/profile_sync_service_mock.cc', + 'browser/sync/profile_sync_service_mock.h', 'browser/ui/browser.h', 'browser/ui/cocoa/browser_test_helper.h', 'common/ipc_test_sink.cc', 'common/ipc_test_sink.h', + 'common/notification_observer_mock.cc', 'common/notification_observer_mock.h', + 'common/pref_store_observer_mock.cc', 'common/pref_store_observer_mock.h', 'renderer/mock_keyboard.cc', 'renderer/mock_keyboard.h', @@ -116,6 +121,7 @@ 'test/chrome_process_util_mac.cc', 'test/model_test_utils.cc', 'test/model_test_utils.h', + 'test/profile_mock.cc', 'test/profile_mock.h', 'test/test_browser_window.h', 'test/test_launcher_utils.cc', @@ -1285,6 +1291,7 @@ 'browser/policy/configuration_policy_provider_win_unittest.cc', 'browser/policy/device_token_fetcher_unittest.cc', 'browser/policy/file_based_policy_provider_unittest.cc', + 'browser/policy/device_management_backend_mock.cc', 'browser/policy/device_management_backend_mock.h', 'browser/policy/device_management_service_unittest.cc', 'browser/policy/device_management_policy_cache_unittest.cc', @@ -1371,9 +1378,12 @@ 'browser/sync/glue/autofill_model_associator_unittest.cc', 'browser/sync/glue/autofill_profile_model_associator_unittest.cc', 'browser/sync/glue/bookmark_data_type_controller_unittest.cc', + 'browser/sync/glue/change_processor_mock.cc', 'browser/sync/glue/change_processor_mock.h', + 'browser/sync/glue/data_type_controller_mock.cc', 'browser/sync/glue/data_type_controller_mock.h', 'browser/sync/glue/data_type_manager_impl_unittest.cc', + 'browser/sync/glue/data_type_manager_mock.cc', 'browser/sync/glue/data_type_manager_mock.h', 'browser/sync/glue/database_model_worker_unittest.cc', 'browser/sync/glue/extension_data_unittest.cc', @@ -1382,6 +1392,7 @@ 'browser/sync/glue/http_bridge_unittest.cc', 'browser/sync/glue/preference_data_type_controller_unittest.cc', 'browser/sync/glue/preference_model_associator_unittest.cc', + 'browser/sync/glue/sync_backend_host_mock.cc', 'browser/sync/glue/sync_backend_host_mock.h', 'browser/sync/glue/theme_data_type_controller_unittest.cc', 'browser/sync/glue/theme_util_unittest.cc', @@ -1391,7 +1402,6 @@ 'browser/sync/profile_sync_factory_mock.cc', 'browser/sync/profile_sync_factory_mock.h', 'browser/sync/profile_sync_service_autofill_unittest.cc', - 'browser/sync/profile_sync_service_mock.h', 'browser/sync/profile_sync_service_password_unittest.cc', 'browser/sync/profile_sync_service_preference_unittest.cc', 'browser/sync/profile_sync_service_session_unittest.cc', @@ -2136,6 +2146,7 @@ 'browser/net/cookie_policy_browsertest.cc', 'browser/net/ftp_browsertest.cc', 'browser/plugin_service_browsertest.cc', + 'browser/policy/device_management_backend_mock.cc', 'browser/policy/device_management_backend_mock.h', 'browser/policy/device_management_service_browsertest.cc', 'browser/popup_blocker_browsertest.cc', @@ -2701,13 +2712,11 @@ 'browser/sync/engine/syncproto_unittest.cc', 'browser/sync/engine/syncapi_mock.h', 'browser/sync/engine/verify_updates_command_unittest.cc', - 'browser/sync/glue/change_processor_mock.h', 'browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc', 'browser/sync/notifier/chrome_invalidation_client_unittest.cc', 'browser/sync/notifier/chrome_system_resources_unittest.cc', 'browser/sync/notifier/registration_manager_unittest.cc', 'browser/sync/notifier/server_notifier_thread_unittest.cc', - 'browser/sync/profile_sync_factory_mock.cc', 'browser/sync/profile_sync_factory_mock.h', 'browser/sync/sessions/ordered_commit_set_unittest.cc', 'browser/sync/sessions/status_controller_unittest.cc', diff --git a/chrome/common/notification_observer_mock.cc b/chrome/common/notification_observer_mock.cc new file mode 100644 index 0000000..634afa5 --- /dev/null +++ b/chrome/common/notification_observer_mock.cc @@ -0,0 +1,12 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/notification_observer_mock.h" + +#include "chrome/common/notification_details.h" +#include "chrome/common/notification_source.h" + +NotificationObserverMock::NotificationObserverMock() {} + +NotificationObserverMock::~NotificationObserverMock() {} diff --git a/chrome/common/notification_observer_mock.h b/chrome/common/notification_observer_mock.h index 0385f26..e232928 100644 --- a/chrome/common/notification_observer_mock.h +++ b/chrome/common/notification_observer_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,8 +15,8 @@ class NotificationSource; class NotificationObserverMock : public NotificationObserver { public: - NotificationObserverMock() {} - virtual ~NotificationObserverMock() {} + NotificationObserverMock(); + virtual ~NotificationObserverMock(); MOCK_METHOD3(Observe, void(NotificationType type, const NotificationSource& source, diff --git a/chrome/common/pref_store_observer_mock.cc b/chrome/common/pref_store_observer_mock.cc new file mode 100644 index 0000000..8d11872 --- /dev/null +++ b/chrome/common/pref_store_observer_mock.cc @@ -0,0 +1,9 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/pref_store_observer_mock.h" + +PrefStoreObserverMock::PrefStoreObserverMock() {} + +PrefStoreObserverMock::~PrefStoreObserverMock() {} diff --git a/chrome/common/pref_store_observer_mock.h b/chrome/common/pref_store_observer_mock.h index 2a49284..3aadf34 100644 --- a/chrome/common/pref_store_observer_mock.h +++ b/chrome/common/pref_store_observer_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,8 +13,8 @@ // A gmock-ified implementation of PrefStore::Observer. class PrefStoreObserverMock : public PrefStore::Observer { public: - PrefStoreObserverMock() {} - virtual ~PrefStoreObserverMock() {} + PrefStoreObserverMock(); + virtual ~PrefStoreObserverMock(); MOCK_METHOD1(OnPrefValueChanged, void(const std::string&)); MOCK_METHOD0(OnInitializationCompleted, void()); diff --git a/chrome/test/profile_mock.cc b/chrome/test/profile_mock.cc new file mode 100644 index 0000000..6e6bb1f --- /dev/null +++ b/chrome/test/profile_mock.cc @@ -0,0 +1,9 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/test/profile_mock.h" + +ProfileMock::ProfileMock() {} + +ProfileMock::~ProfileMock() {} diff --git a/chrome/test/profile_mock.h b/chrome/test/profile_mock.h index b3b0dcf..73770c8 100644 --- a/chrome/test/profile_mock.h +++ b/chrome/test/profile_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,6 +12,9 @@ class ProfileMock : public TestingProfile { public: + ProfileMock(); + virtual ~ProfileMock(); + MOCK_METHOD0(GetBookmarkModel, BookmarkModel*()); MOCK_METHOD1(GetHistoryService, HistoryService*(ServiceAccessType access)); MOCK_METHOD0(GetHistoryServiceWithoutCreating, HistoryService*()); diff --git a/gpu/command_buffer/common/command_buffer_mock.cc b/gpu/command_buffer/common/command_buffer_mock.cc new file mode 100644 index 0000000..d92c2c3 --- /dev/null +++ b/gpu/command_buffer/common/command_buffer_mock.cc @@ -0,0 +1,18 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gpu/command_buffer/common/command_buffer_mock.h" + +namespace gpu { + +MockCommandBuffer::MockCommandBuffer() { + ON_CALL(*this, GetRingBuffer()) + .WillByDefault(testing::Return(Buffer())); + ON_CALL(*this, GetTransferBuffer(testing::_)) + .WillByDefault(testing::Return(Buffer())); +} + +MockCommandBuffer::~MockCommandBuffer() {} + +} // namespace gpu diff --git a/gpu/command_buffer/common/command_buffer_mock.h b/gpu/command_buffer/common/command_buffer_mock.h index eb78b83..97cd3cf 100644 --- a/gpu/command_buffer/common/command_buffer_mock.h +++ b/gpu/command_buffer/common/command_buffer_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,12 +14,8 @@ namespace gpu { // API to manage the put and get pointers. class MockCommandBuffer : public CommandBuffer { public: - MockCommandBuffer() { - ON_CALL(*this, GetRingBuffer()) - .WillByDefault(testing::Return(Buffer())); - ON_CALL(*this, GetTransferBuffer(testing::_)) - .WillByDefault(testing::Return(Buffer())); - } + MockCommandBuffer(); + virtual ~MockCommandBuffer(); MOCK_METHOD1(Initialize, bool(int32 size)); MOCK_METHOD0(GetRingBuffer, Buffer()); diff --git a/gpu/command_buffer/service/mocks.cc b/gpu/command_buffer/service/mocks.cc new file mode 100644 index 0000000..6f267be --- /dev/null +++ b/gpu/command_buffer/service/mocks.cc @@ -0,0 +1,34 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gpu/command_buffer/service/mocks.h" + +namespace gpu { + +AsyncAPIMock::AsyncAPIMock() { + testing::DefaultValue<error::Error>::Set( + error::kNoError); +} + +AsyncAPIMock::~AsyncAPIMock() {} + +void AsyncAPIMock::SetToken(unsigned int command, + unsigned int arg_count, + const void* _args) { + DCHECK(engine_); + DCHECK_EQ(1u, command); + DCHECK_EQ(1u, arg_count); + const CommandBufferEntry* args = + static_cast<const CommandBufferEntry*>(_args); + engine_->set_token(args[0].value_uint32); +} + +namespace gles2 { + +MockShaderTranslator::MockShaderTranslator() {} + +MockShaderTranslator::~MockShaderTranslator() {} + +} // namespace gles2 +} // namespace gpu diff --git a/gpu/command_buffer/service/mocks.h b/gpu/command_buffer/service/mocks.h index 8a11aee..0d341bd 100644 --- a/gpu/command_buffer/service/mocks.h +++ b/gpu/command_buffer/service/mocks.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,10 +23,8 @@ namespace gpu { // Mocks an AsyncAPIInterface, using GMock. class AsyncAPIMock : public AsyncAPIInterface { public: - AsyncAPIMock() { - testing::DefaultValue<error::Error>::Set( - error::kNoError); - } + AsyncAPIMock(); + virtual ~AsyncAPIMock(); // Predicate that matches args passed to DoCommand, by looking at the values. class IsArgs { @@ -65,14 +63,8 @@ class AsyncAPIMock : public AsyncAPIInterface { // Forwards the SetToken commands to the engine. void SetToken(unsigned int command, unsigned int arg_count, - const void* _args) { - DCHECK(engine_); - DCHECK_EQ(1u, command); - DCHECK_EQ(1u, arg_count); - const CommandBufferEntry* args = - static_cast<const CommandBufferEntry*>(_args); - engine_->set_token(args[0].value_uint32); - } + const void* _args); + private: CommandBufferEngine *engine_; }; @@ -81,7 +73,8 @@ namespace gles2 { class MockShaderTranslator : public ShaderTranslatorInterface { public: - virtual ~MockShaderTranslator() { } + MockShaderTranslator(); + virtual ~MockShaderTranslator(); MOCK_METHOD4(Init, bool( ShShaderType shader_type, diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index d6467e7..bd9fbb0 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -1,4 +1,4 @@ -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -24,7 +24,6 @@ 'command_buffer/common/cmd_buffer_common.h', 'command_buffer/common/cmd_buffer_common.cc', 'command_buffer/common/command_buffer.h', - 'command_buffer/common/command_buffer_mock.h', 'command_buffer/common/constants.h', 'command_buffer/common/gles2_cmd_ids_autogen.h', 'command_buffer/common/gles2_cmd_ids.h', @@ -36,7 +35,6 @@ 'command_buffer/common/id_allocator.cc', 'command_buffer/common/id_allocator.h', 'command_buffer/common/logging.h', - 'command_buffer/common/mocks.h', 'command_buffer/common/thread_local.h', 'command_buffer/common/types.h', ], @@ -229,6 +227,8 @@ 'command_buffer/client/mapped_memory_unittest.cc', 'command_buffer/client/ring_buffer_test.cc', 'command_buffer/common/bitfield_helpers_test.cc', + 'command_buffer/common/command_buffer_mock.cc', + 'command_buffer/common/command_buffer_mock.h', 'command_buffer/common/gl_mock.h', 'command_buffer/common/gl_mock.cc', 'command_buffer/common/gles2_cmd_format_test.cc', @@ -261,6 +261,8 @@ 'command_buffer/service/gles2_cmd_decoder_unittest_2.cc', 'command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h', 'command_buffer/service/id_manager_unittest.cc', + 'command_buffer/service/mocks.cc', + 'command_buffer/service/mocks.h', 'command_buffer/service/program_manager_unittest.cc', 'command_buffer/service/renderbuffer_manager_unittest.cc', 'command_buffer/service/shader_manager_unittest.cc', diff --git a/media/base/mock_filter_host.cc b/media/base/mock_filter_host.cc new file mode 100644 index 0000000..9c5e184 --- /dev/null +++ b/media/base/mock_filter_host.cc @@ -0,0 +1,13 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/base/mock_filter_host.h" + +namespace media { + +MockFilterHost::MockFilterHost() {} + +MockFilterHost::~MockFilterHost() {} + +} // namespace media diff --git a/media/base/mock_filter_host.h b/media/base/mock_filter_host.h index 9043854..aecc3f6 100644 --- a/media/base/mock_filter_host.h +++ b/media/base/mock_filter_host.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -19,7 +19,8 @@ namespace media { class MockFilterHost : public FilterHost { public: - MockFilterHost() {} + MockFilterHost(); + virtual ~MockFilterHost(); // FilterHost implementation. MOCK_METHOD0(InitializationComplete, void()); diff --git a/media/base/mock_filters.cc b/media/base/mock_filters.cc index f2110ff..3347016 100644 --- a/media/base/mock_filters.cc +++ b/media/base/mock_filters.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,6 +6,68 @@ namespace media { +MockFilterCallback::MockFilterCallback() {} + +MockFilterCallback::~MockFilterCallback() {} + +FilterCallback* MockFilterCallback::NewCallback() { + return new CallbackImpl(this); +} + +MockDataSource::MockDataSource() {} + +MockDataSource::~MockDataSource() {} + +MockDemuxer::MockDemuxer() {} + +MockDemuxer::~MockDemuxer() {} + +MockDemuxerStream::MockDemuxerStream() {} + +MockDemuxerStream::~MockDemuxerStream() {} + +MockVideoDecoder::MockVideoDecoder() {} + +MockVideoDecoder::~MockVideoDecoder() {} + +MockAudioDecoder::MockAudioDecoder() {} + +MockAudioDecoder::~MockAudioDecoder() {} + +MockVideoRenderer::MockVideoRenderer() {} + +MockVideoRenderer::~MockVideoRenderer() {} + +MockAudioRenderer::MockAudioRenderer() {} + +MockAudioRenderer::~MockAudioRenderer() {} + +MockFilterCollection::MockFilterCollection() + : data_source_(new MockDataSource()), + demuxer_(new MockDemuxer()), + video_decoder_(new MockVideoDecoder()), + audio_decoder_(new MockAudioDecoder()), + video_renderer_(new MockVideoRenderer()), + audio_renderer_(new MockAudioRenderer()) { +} + +MockFilterCollection::~MockFilterCollection() {} + +FilterCollection* MockFilterCollection::filter_collection( + bool include_data_source) const { + FilterCollection* collection = new FilterCollection(); + + if (include_data_source) { + collection->AddDataSource(data_source_); + } + collection->AddDemuxer(demuxer_); + collection->AddVideoDecoder(video_decoder_); + collection->AddAudioDecoder(audio_decoder_); + collection->AddVideoRenderer(video_renderer_); + collection->AddAudioRenderer(audio_renderer_); + return collection; +} + void RunFilterCallback(::testing::Unused, FilterCallback* callback) { callback->Run(); delete callback; diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h index 3b1deb3..5b5677b 100644 --- a/media/base/mock_filters.h +++ b/media/base/mock_filters.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -50,8 +50,8 @@ class Destroyable : public MockClass { // gmock will track the number of times the methods are executed. class MockFilterCallback { public: - MockFilterCallback() {} - virtual ~MockFilterCallback() {} + MockFilterCallback(); + virtual ~MockFilterCallback(); MOCK_METHOD0(OnCallbackDestroyed, void()); MOCK_METHOD0(OnFilterCallback, void()); @@ -60,9 +60,7 @@ class MockFilterCallback { // call OnFilterCallback() when executed and OnCallbackDestroyed() when // destroyed. Clients should use NiceMock<> or StrictMock<> depending on the // test. - FilterCallback* NewCallback() { - return new CallbackImpl(this); - } + FilterCallback* NewCallback(); private: // Private implementation of CallbackRunner used to trigger expectations on @@ -92,7 +90,7 @@ class MockFilterCallback { class MockDataSource : public DataSource { public: - MockDataSource() {} + MockDataSource(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -111,7 +109,7 @@ class MockDataSource : public DataSource { MOCK_METHOD0(IsStreaming, bool()); protected: - virtual ~MockDataSource() {} + virtual ~MockDataSource(); private: DISALLOW_COPY_AND_ASSIGN(MockDataSource); @@ -119,7 +117,7 @@ class MockDataSource : public DataSource { class MockDemuxer : public Demuxer { public: - MockDemuxer() {} + MockDemuxer(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -134,7 +132,7 @@ class MockDemuxer : public Demuxer { MOCK_METHOD1(GetStream, scoped_refptr<DemuxerStream>(int stream_id)); protected: - virtual ~MockDemuxer() {} + virtual ~MockDemuxer(); private: DISALLOW_COPY_AND_ASSIGN(MockDemuxer); @@ -142,7 +140,7 @@ class MockDemuxer : public Demuxer { class MockDemuxerStream : public DemuxerStream { public: - MockDemuxerStream() {} + MockDemuxerStream(); // DemuxerStream implementation. MOCK_METHOD0(media_format, const MediaFormat&()); @@ -151,7 +149,7 @@ class MockDemuxerStream : public DemuxerStream { MOCK_METHOD0(EnableBitstreamConverter, void()); protected: - virtual ~MockDemuxerStream() {} + virtual ~MockDemuxerStream(); private: MediaFormat media_format_; @@ -161,7 +159,7 @@ class MockDemuxerStream : public DemuxerStream { class MockVideoDecoder : public VideoDecoder { public: - MockVideoDecoder() {} + MockVideoDecoder(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -182,7 +180,7 @@ class MockVideoDecoder : public VideoDecoder { } protected: - virtual ~MockVideoDecoder() {} + virtual ~MockVideoDecoder(); private: DISALLOW_COPY_AND_ASSIGN(MockVideoDecoder); @@ -190,7 +188,7 @@ class MockVideoDecoder : public VideoDecoder { class MockAudioDecoder : public AudioDecoder { public: - MockAudioDecoder() {} + MockAudioDecoder(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -210,7 +208,7 @@ class MockAudioDecoder : public AudioDecoder { } protected: - virtual ~MockAudioDecoder() {} + virtual ~MockAudioDecoder(); private: DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder); @@ -218,7 +216,7 @@ class MockAudioDecoder : public AudioDecoder { class MockVideoRenderer : public VideoRenderer { public: - MockVideoRenderer() {} + MockVideoRenderer(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -233,7 +231,7 @@ class MockVideoRenderer : public VideoRenderer { MOCK_METHOD1(ConsumeVideoFrame, void(scoped_refptr<VideoFrame> frame)); protected: - virtual ~MockVideoRenderer() {} + virtual ~MockVideoRenderer(); private: DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer); @@ -241,7 +239,7 @@ class MockVideoRenderer : public VideoRenderer { class MockAudioRenderer : public AudioRenderer { public: - MockAudioRenderer() {} + MockAudioRenderer(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -256,7 +254,7 @@ class MockAudioRenderer : public AudioRenderer { MOCK_METHOD1(SetVolume, void(float volume)); protected: - virtual ~MockAudioRenderer() {} + virtual ~MockAudioRenderer(); private: DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer); @@ -266,16 +264,8 @@ class MockAudioRenderer : public AudioRenderer { // expectations on the filters and then pass the collection into a pipeline. class MockFilterCollection { public: - MockFilterCollection() - : data_source_(new MockDataSource()), - demuxer_(new MockDemuxer()), - video_decoder_(new MockVideoDecoder()), - audio_decoder_(new MockAudioDecoder()), - video_renderer_(new MockVideoRenderer()), - audio_renderer_(new MockAudioRenderer()) { - } - - virtual ~MockFilterCollection() {} + MockFilterCollection(); + virtual ~MockFilterCollection(); // Mock accessors. MockDataSource* data_source() const { return data_source_; } @@ -289,19 +279,7 @@ class MockFilterCollection { return filter_collection(true); } - FilterCollection* filter_collection(bool include_data_source) const { - FilterCollection* collection = new FilterCollection(); - - if (include_data_source) { - collection->AddDataSource(data_source_); - } - collection->AddDemuxer(demuxer_); - collection->AddVideoDecoder(video_decoder_); - collection->AddAudioDecoder(audio_decoder_); - collection->AddVideoRenderer(video_renderer_); - collection->AddAudioRenderer(audio_renderer_); - return collection; - } + FilterCollection* filter_collection(bool include_data_source) const; private: scoped_refptr<MockDataSource> data_source_; diff --git a/media/base/mock_task.cc b/media/base/mock_task.cc new file mode 100644 index 0000000..f9f8823 --- /dev/null +++ b/media/base/mock_task.cc @@ -0,0 +1,22 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/base/mock_task.h" + +namespace media { + +TaskMocker::TaskMocker() + : outstanding_tasks_(0) { +} + +TaskMocker::~TaskMocker() { + CHECK(outstanding_tasks_ == 0) + << "If outstanding_tasks_ is not zero, tasks have been leaked."; +} + +Task* TaskMocker::CreateTask() { + return new CountingTask(this); +} + +} // namespace media diff --git a/media/base/mock_task.h b/media/base/mock_task.h index cb6e0de..6d418a1 100644 --- a/media/base/mock_task.h +++ b/media/base/mock_task.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -63,17 +63,10 @@ ACTION(InvokeRunnable) { class TaskMocker { public: - TaskMocker() - : outstanding_tasks_(0) { - } - ~TaskMocker() { - CHECK(outstanding_tasks_ == 0) - << "If outstanding_tasks_ is not zero, tasks have been leaked."; - } - - Task* CreateTask() { - return new CountingTask(this); - } + TaskMocker(); + ~TaskMocker(); + + Task* CreateTask(); MOCK_METHOD0(Run, void()); diff --git a/media/media.gyp b/media/media.gyp index 6fe8e83..0a02903 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -1,4 +1,4 @@ -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -211,6 +211,7 @@ 'type': 'executable', 'dependencies': [ 'media', + 'media_test_support', '../base/base.gyp:base', '../base/base.gyp:base_i18n', '../base/base.gyp:test_support_base', @@ -246,6 +247,7 @@ 'msvs_guid': 'C8C6183C-B03C-11DD-B471-DFD256D89593', 'dependencies': [ 'media', + 'media_test_support', '../base/base.gyp:base', '../base/base.gyp:base_i18n', '../base/base.gyp:test_support_base', @@ -275,10 +277,8 @@ 'base/filter_collection_unittest.cc', 'base/mock_ffmpeg.cc', 'base/mock_ffmpeg.h', - 'base/mock_filter_host.h', - 'base/mock_filters.cc', - 'base/mock_filters.h', 'base/mock_reader.h', + 'base/mock_task.cc', 'base/mock_task.h', 'base/pipeline_impl_unittest.cc', 'base/pts_heap_unittest.cc', @@ -328,10 +328,16 @@ 'dependencies': [ 'media', '../base/base.gyp:base', + '../testing/gmock.gyp:gmock', + '../testing/gtest.gyp:gtest', ], 'sources': [ 'audio/test_audio_input_controller_factory.cc', 'audio/test_audio_input_controller_factory.h', + 'base/mock_filter_host.cc', + 'base/mock_filter_host.h', + 'base/mock_filters.cc', + 'base/mock_filters.h', ], }, { diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index abf1fb0..dae1a98 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -1,4 +1,4 @@ -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -351,6 +351,7 @@ 'dependencies': [ 'test_shell_common', '<(DEPTH)/base/base.gyp:test_support_base', + '<(DEPTH)/media/media.gyp:media_test_support', '<(DEPTH)/net/net.gyp:net_test_support', '<(DEPTH)/skia/skia.gyp:skia', '<(DEPTH)/testing/gmock.gyp:gmock', |