1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_TEST_UTIL_H_ 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_TEST_UTIL_H_ 7 8 #include <vector> 9 10 #include "base/files/file.h" 11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_vector.h" 13 14 namespace extensions { 15 struct Event; 16 } // namespace extensions 17 18 namespace chromeos { 19 namespace file_system_provider { 20 namespace operations { 21 namespace util { 22 23 // Fake event dispatcher implementation with extra logging capability. Acts as 24 // a providing extension end-point. 25 class LoggingDispatchEventImpl { 26 public: 27 explicit LoggingDispatchEventImpl(bool dispatch_reply); 28 virtual ~LoggingDispatchEventImpl(); 29 30 // Handles sending an event to a providing extension. 31 bool OnDispatchEventImpl(scoped_ptr<extensions::Event> event); 32 33 // Returns events sent to providing extensions. 34 ScopedVector<extensions::Event>& events() { return events_; } 35 36 private: 37 ScopedVector<extensions::Event> events_; 38 bool dispatch_reply_; 39 40 DISALLOW_COPY_AND_ASSIGN(LoggingDispatchEventImpl); 41 }; 42 43 // Container for remembering operations' callback invocations. 44 typedef std::vector<base::File::Error> StatusCallbackLog; 45 46 // Pushes a result of the StatusCallback invocation to a log vector. 47 void LogStatusCallback(StatusCallbackLog* log, base::File::Error result); 48 49 } // namespace util 50 } // namespace operations 51 } // namespace file_system_provider 52 } // namespace chromeos 53 54 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_TEST_UTIL_H_ 55