namespace syncer {
+namespace {
+
class MockAttachmentStore : public AttachmentStore,
public base::SupportsWeakPtr<MockAttachmentStore> {
public:
MockAttachmentStore() {}
- virtual void Read(const AttachmentIdList& ids,
- const ReadCallback& callback) OVERRIDE {
+ void Read(const AttachmentIdList& ids,
+ const ReadCallback& callback) override {
read_ids.push_back(ids);
read_callbacks.push_back(callback);
}
- virtual void Write(const AttachmentList& attachments,
- const WriteCallback& callback) OVERRIDE {
+ void Write(const AttachmentList& attachments,
+ const WriteCallback& callback) override {
write_attachments.push_back(attachments);
write_callbacks.push_back(callback);
}
- virtual void Drop(const AttachmentIdList& ids,
- const DropCallback& callback) OVERRIDE {
+ void Drop(const AttachmentIdList& ids,
+ const DropCallback& callback) override {
NOTREACHED();
}
std::vector<WriteCallback> write_callbacks;
private:
- virtual ~MockAttachmentStore() {}
+ ~MockAttachmentStore() override {}
DISALLOW_COPY_AND_ASSIGN(MockAttachmentStore);
};
public:
MockAttachmentDownloader() {}
- virtual void DownloadAttachment(const AttachmentId& id,
- const DownloadCallback& callback) OVERRIDE {
+ void DownloadAttachment(const AttachmentId& id,
+ const DownloadCallback& callback) override {
ASSERT_TRUE(download_requests.find(id) == download_requests.end());
download_requests.insert(std::make_pair(id, callback));
}
MockAttachmentUploader() {}
// AttachmentUploader implementation.
- virtual void UploadAttachment(const Attachment& attachment,
- const UploadCallback& callback) OVERRIDE {
+ void UploadAttachment(const Attachment& attachment,
+ const UploadCallback& callback) override {
const AttachmentId id = attachment.GetId();
ASSERT_TRUE(upload_requests.find(id) == upload_requests.end());
upload_requests.insert(std::make_pair(id, callback));
DISALLOW_COPY_AND_ASSIGN(MockAttachmentUploader);
};
+} // namespace
+
class AttachmentServiceImplTest : public testing::Test,
public AttachmentService::Delegate {
protected:
AttachmentServiceImplTest() {}
- virtual void SetUp() OVERRIDE {
+ virtual void SetUp() override {
network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock());
InitializeAttachmentService(make_scoped_ptr(new MockAttachmentUploader()),
make_scoped_ptr(new MockAttachmentDownloader()),
this);
}
- virtual void TearDown() OVERRIDE {
+ virtual void TearDown() override {
attachment_service_.reset();
ASSERT_FALSE(attachment_store_);
ASSERT_FALSE(attachment_uploader_);
}
// AttachmentService::Delegate implementation.
- virtual void OnAttachmentUploaded(
- const AttachmentId& attachment_id) OVERRIDE {
+ void OnAttachmentUploaded(const AttachmentId& attachment_id) override {
on_attachment_uploaded_list_.push_back(attachment_id);
}
}
attachment_service_.reset(
new AttachmentServiceImpl(attachment_store,
- uploader.PassAs<AttachmentUploader>(),
- downloader.PassAs<AttachmentDownloader>(),
+ uploader.Pass(),
+ downloader.Pass(),
delegate,
base::TimeDelta::FromMinutes(1),
base::TimeDelta::FromMinutes(8)));
scoped_ptr<base::MockTimer> timer_to_pass(
new base::MockTimer(false, false));
mock_timer_ = timer_to_pass.get();
- attachment_service_->SetTimerForTest(timer_to_pass.PassAs<base::Timer>());
+ attachment_service_->SetTimerForTest(timer_to_pass.Pass());
}
AttachmentService* attachment_service() { return attachment_service_.get(); }