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.
5 #ifndef WEBKIT_BROWSER_FILEAPI_MOCK_FILE_CHANGE_OBSERVER_H_
6 #define WEBKIT_BROWSER_FILEAPI_MOCK_FILE_CHANGE_OBSERVER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "storage/browser/fileapi/file_observers.h"
11 #include "storage/browser/fileapi/file_system_url.h"
12 #include "storage/browser/fileapi/task_runner_bound_observer_list.h"
16 // Mock file change observer.
17 class MockFileChangeObserver
: public FileChangeObserver
{
19 MockFileChangeObserver();
20 virtual ~MockFileChangeObserver();
22 // Creates a ChangeObserverList which only contains given |observer|.
23 static ChangeObserverList
CreateList(MockFileChangeObserver
* observer
);
25 // FileChangeObserver overrides.
26 virtual void OnCreateFile(const FileSystemURL
& url
) OVERRIDE
;
27 virtual void OnCreateFileFrom(const FileSystemURL
& url
,
28 const FileSystemURL
& src
) OVERRIDE
;
29 virtual void OnRemoveFile(const FileSystemURL
& url
) OVERRIDE
;
30 virtual void OnModifyFile(const FileSystemURL
& url
) OVERRIDE
;
31 virtual void OnCreateDirectory(const FileSystemURL
& url
) OVERRIDE
;
32 virtual void OnRemoveDirectory(const FileSystemURL
& url
) OVERRIDE
;
35 create_file_count_
= 0;
36 create_file_from_count_
= 0;
37 remove_file_count_
= 0;
38 modify_file_count_
= 0;
39 create_directory_count_
= 0;
40 remove_directory_count_
= 0;
43 bool HasNoChange() const {
44 return create_file_count_
== 0 &&
45 create_file_from_count_
== 0 &&
46 remove_file_count_
== 0 &&
47 modify_file_count_
== 0 &&
48 create_directory_count_
== 0 &&
49 remove_directory_count_
== 0;
52 int create_file_count() const { return create_file_count_
; }
53 int create_file_from_count() const { return create_file_from_count_
; }
54 int remove_file_count() const { return remove_file_count_
; }
55 int modify_file_count() const { return modify_file_count_
; }
56 int create_directory_count() const { return create_directory_count_
; }
57 int remove_directory_count() const { return remove_directory_count_
; }
59 int get_and_reset_create_file_count() {
60 int tmp
= create_file_count_
;
61 create_file_count_
= 0;
64 int get_and_reset_create_file_from_count() {
65 int tmp
= create_file_from_count_
;
66 create_file_from_count_
= 0;
69 int get_and_reset_remove_file_count() {
70 int tmp
= remove_file_count_
;
71 remove_file_count_
= 0;
74 int get_and_reset_modify_file_count() {
75 int tmp
= modify_file_count_
;
76 modify_file_count_
= 0;
79 int get_and_reset_create_directory_count() {
80 int tmp
= create_directory_count_
;
81 create_directory_count_
= 0;
84 int get_and_reset_remove_directory_count() {
85 int tmp
= remove_directory_count_
;
86 remove_directory_count_
= 0;
91 int create_file_count_
;
92 int create_file_from_count_
;
93 int remove_file_count_
;
94 int modify_file_count_
;
95 int create_directory_count_
;
96 int remove_directory_count_
;
98 DISALLOW_COPY_AND_ASSIGN(MockFileChangeObserver
);
101 } // namespace storage
103 #endif // WEBKIT_BROWSER_FILEAPI_MOCK_FILE_CHANGE_OBSERVER_H_