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

Side by Side Diff: webkit/plugins/ppapi/quota_file_io_unittest.cc

Issue 8231004: Remaining cleanup (base::Bind): Replacing FileUtilProxy calls with new callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 2 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 (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 <deque> 5 #include <deque>
6 #include <limits> 6 #include <limits>
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/scoped_callback_factory.h"
12 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop.h" 12 #include "base/message_loop.h"
14 #include "base/platform_file.h" 13 #include "base/platform_file.h"
15 #include "base/scoped_temp_dir.h" 14 #include "base/scoped_temp_dir.h"
16 #include "base/task.h" 15 #include "base/task.h"
17 #include "webkit/plugins/ppapi/mock_plugin_delegate.h" 16 #include "webkit/plugins/ppapi/mock_plugin_delegate.h"
18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 17 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
19 #include "webkit/plugins/ppapi/ppapi_unittest.h" 18 #include "webkit/plugins/ppapi/ppapi_unittest.h"
20 #include "webkit/plugins/ppapi/quota_file_io.h" 19 #include "webkit/plugins/ppapi/quota_file_io.h"
21 20
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 int will_update_count_; 77 int will_update_count_;
79 GURL file_path_; 78 GURL file_path_;
80 scoped_refptr<MessageLoopProxy> file_thread_; 79 scoped_refptr<MessageLoopProxy> file_thread_;
81 base::WeakPtrFactory<QuotaMockPluginDelegate> weak_factory_; 80 base::WeakPtrFactory<QuotaMockPluginDelegate> weak_factory_;
82 }; 81 };
83 } // namespace 82 } // namespace
84 83
85 class QuotaFileIOTest : public PpapiUnittest { 84 class QuotaFileIOTest : public PpapiUnittest {
86 public: 85 public:
87 QuotaFileIOTest() 86 QuotaFileIOTest()
88 : ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)), 87 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {}
89 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {}
90 88
91 virtual void SetUp() OVERRIDE { 89 virtual void SetUp() OVERRIDE {
92 PpapiUnittest::SetUp(); 90 PpapiUnittest::SetUp();
93 ASSERT_TRUE(dir_.CreateUniqueTempDir()); 91 ASSERT_TRUE(dir_.CreateUniqueTempDir());
94 FilePath path; 92 FilePath path;
95 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(dir_.path(), &path)); 93 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(dir_.path(), &path));
96 int file_flags = base::PLATFORM_FILE_OPEN | 94 int file_flags = base::PLATFORM_FILE_OPEN |
97 base::PLATFORM_FILE_READ | 95 base::PLATFORM_FILE_READ |
98 base::PLATFORM_FILE_WRITE | 96 base::PLATFORM_FILE_WRITE |
99 base::PLATFORM_FILE_WRITE_ATTRIBUTES; 97 base::PLATFORM_FILE_WRITE_ATTRIBUTES;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 void SetPlatformFileSize(int64_t length) { 421 void SetPlatformFileSize(int64_t length) {
424 EXPECT_TRUE(base::TruncatePlatformFile(file_, length)); 422 EXPECT_TRUE(base::TruncatePlatformFile(file_, length));
425 } 423 }
426 424
427 private: 425 private:
428 ScopedTempDir dir_; 426 ScopedTempDir dir_;
429 PlatformFile file_; 427 PlatformFile file_;
430 scoped_ptr<QuotaFileIO> quota_file_io_; 428 scoped_ptr<QuotaFileIO> quota_file_io_;
431 std::deque<int> bytes_written_; 429 std::deque<int> bytes_written_;
432 std::deque<PlatformFileError> status_; 430 std::deque<PlatformFileError> status_;
433 base::ScopedCallbackFactory<QuotaFileIOTest> callback_factory_;
434 base::WeakPtrFactory<QuotaFileIOTest> weak_factory_; 431 base::WeakPtrFactory<QuotaFileIOTest> weak_factory_;
435 }; 432 };
436 433
437 TEST_F(QuotaFileIOTest, Write) { 434 TEST_F(QuotaFileIOTest, Write) {
438 WriteTestBody(false); 435 WriteTestBody(false);
439 } 436 }
440 437
441 TEST_F(QuotaFileIOTest, WillWrite) { 438 TEST_F(QuotaFileIOTest, WillWrite) {
442 WriteTestBody(true); 439 WriteTestBody(true);
443 } 440 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 pop_result(); 491 pop_result();
495 492
496 EXPECT_EQ(22 - 15, quota_plugin_delegate()->available_space()); 493 EXPECT_EQ(22 - 15, quota_plugin_delegate()->available_space());
497 EXPECT_EQ(15, GetPlatformFileSize()); 494 EXPECT_EQ(15, GetPlatformFileSize());
498 ReadPlatformFile(&read_buffer); 495 ReadPlatformFile(&read_buffer);
499 EXPECT_EQ("123355559012345", read_buffer); 496 EXPECT_EQ("123355559012345", read_buffer);
500 } 497 }
501 498
502 } // namespace ppapi 499 } // namespace ppapi
503 } // namespace webkit 500 } // namespace webkit
OLDNEW
« base/file_util_proxy.cc ('K') | « webkit/plugins/ppapi/quota_file_io.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698