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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/unobserve_entry_unittest.cc

Issue 679573002: [fsp] Separate recursive and non-recursive watchers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/chromeos/file_system_provider/operations/unobserve_entr y.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/unobserve_entr y.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 TEST_F(FileSystemProviderOperationsUnobserveEntryTest, Execute) { 49 TEST_F(FileSystemProviderOperationsUnobserveEntryTest, Execute) {
50 using extensions::api::file_system_provider::UnobserveEntryRequestedOptions; 50 using extensions::api::file_system_provider::UnobserveEntryRequestedOptions;
51 51
52 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 52 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
53 util::StatusCallbackLog callback_log; 53 util::StatusCallbackLog callback_log;
54 54
55 UnobserveEntry unobserve_entry( 55 UnobserveEntry unobserve_entry(
56 NULL, 56 NULL,
57 file_system_info_, 57 file_system_info_,
58 base::FilePath::FromUTF8Unsafe(kEntryPath), 58 base::FilePath::FromUTF8Unsafe(kEntryPath),
59 true /* recursive */,
59 base::Bind(&util::LogStatusCallback, &callback_log)); 60 base::Bind(&util::LogStatusCallback, &callback_log));
60 unobserve_entry.SetDispatchEventImplForTesting( 61 unobserve_entry.SetDispatchEventImplForTesting(
61 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 62 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
62 base::Unretained(&dispatcher))); 63 base::Unretained(&dispatcher)));
63 64
64 EXPECT_TRUE(unobserve_entry.Execute(kRequestId)); 65 EXPECT_TRUE(unobserve_entry.Execute(kRequestId));
65 66
66 ASSERT_EQ(1u, dispatcher.events().size()); 67 ASSERT_EQ(1u, dispatcher.events().size());
67 extensions::Event* event = dispatcher.events()[0]; 68 extensions::Event* event = dispatcher.events()[0];
68 EXPECT_EQ(extensions::api::file_system_provider::OnUnobserveEntryRequested:: 69 EXPECT_EQ(extensions::api::file_system_provider::OnUnobserveEntryRequested::
69 kEventName, 70 kEventName,
70 event->event_name); 71 event->event_name);
71 base::ListValue* event_args = event->event_args.get(); 72 base::ListValue* event_args = event->event_args.get();
72 ASSERT_EQ(1u, event_args->GetSize()); 73 ASSERT_EQ(1u, event_args->GetSize());
73 74
74 const base::DictionaryValue* options_as_value = NULL; 75 const base::DictionaryValue* options_as_value = NULL;
75 ASSERT_TRUE(event_args->GetDictionary(0, &options_as_value)); 76 ASSERT_TRUE(event_args->GetDictionary(0, &options_as_value));
76 77
77 UnobserveEntryRequestedOptions options; 78 UnobserveEntryRequestedOptions options;
78 ASSERT_TRUE( 79 ASSERT_TRUE(
79 UnobserveEntryRequestedOptions::Populate(*options_as_value, &options)); 80 UnobserveEntryRequestedOptions::Populate(*options_as_value, &options));
80 EXPECT_EQ(kFileSystemId, options.file_system_id); 81 EXPECT_EQ(kFileSystemId, options.file_system_id);
81 EXPECT_EQ(kRequestId, options.request_id); 82 EXPECT_EQ(kRequestId, options.request_id);
82 EXPECT_EQ(kEntryPath, options.entry_path); 83 EXPECT_EQ(kEntryPath, options.entry_path);
84 EXPECT_TRUE(options.recursive);
83 } 85 }
84 86
85 TEST_F(FileSystemProviderOperationsUnobserveEntryTest, Execute_NoListener) { 87 TEST_F(FileSystemProviderOperationsUnobserveEntryTest, Execute_NoListener) {
86 util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); 88 util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */);
87 util::StatusCallbackLog callback_log; 89 util::StatusCallbackLog callback_log;
88 90
89 UnobserveEntry unobserve_entry( 91 UnobserveEntry unobserve_entry(
90 NULL, 92 NULL,
91 file_system_info_, 93 file_system_info_,
92 base::FilePath::FromUTF8Unsafe(kEntryPath), 94 base::FilePath::FromUTF8Unsafe(kEntryPath),
95 true /* recursive */,
93 base::Bind(&util::LogStatusCallback, &callback_log)); 96 base::Bind(&util::LogStatusCallback, &callback_log));
94 unobserve_entry.SetDispatchEventImplForTesting( 97 unobserve_entry.SetDispatchEventImplForTesting(
95 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 98 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
96 base::Unretained(&dispatcher))); 99 base::Unretained(&dispatcher)));
97 100
98 EXPECT_FALSE(unobserve_entry.Execute(kRequestId)); 101 EXPECT_FALSE(unobserve_entry.Execute(kRequestId));
99 } 102 }
100 103
101 TEST_F(FileSystemProviderOperationsUnobserveEntryTest, OnSuccess) { 104 TEST_F(FileSystemProviderOperationsUnobserveEntryTest, OnSuccess) {
102 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 105 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
103 util::StatusCallbackLog callback_log; 106 util::StatusCallbackLog callback_log;
104 107
105 UnobserveEntry unobserve_entry( 108 UnobserveEntry unobserve_entry(
106 NULL, 109 NULL,
107 file_system_info_, 110 file_system_info_,
108 base::FilePath::FromUTF8Unsafe(kEntryPath), 111 base::FilePath::FromUTF8Unsafe(kEntryPath),
112 true /* recursive */,
109 base::Bind(&util::LogStatusCallback, &callback_log)); 113 base::Bind(&util::LogStatusCallback, &callback_log));
110 unobserve_entry.SetDispatchEventImplForTesting( 114 unobserve_entry.SetDispatchEventImplForTesting(
111 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 115 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
112 base::Unretained(&dispatcher))); 116 base::Unretained(&dispatcher)));
113 117
114 EXPECT_TRUE(unobserve_entry.Execute(kRequestId)); 118 EXPECT_TRUE(unobserve_entry.Execute(kRequestId));
115 119
116 unobserve_entry.OnSuccess(kRequestId, 120 unobserve_entry.OnSuccess(kRequestId,
117 scoped_ptr<RequestValue>(new RequestValue()), 121 scoped_ptr<RequestValue>(new RequestValue()),
118 false /* has_more */); 122 false /* has_more */);
119 ASSERT_EQ(1u, callback_log.size()); 123 ASSERT_EQ(1u, callback_log.size());
120 EXPECT_EQ(base::File::FILE_OK, callback_log[0]); 124 EXPECT_EQ(base::File::FILE_OK, callback_log[0]);
121 } 125 }
122 126
123 TEST_F(FileSystemProviderOperationsUnobserveEntryTest, OnError) { 127 TEST_F(FileSystemProviderOperationsUnobserveEntryTest, OnError) {
124 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 128 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
125 util::StatusCallbackLog callback_log; 129 util::StatusCallbackLog callback_log;
126 130
127 UnobserveEntry unobserve_entry( 131 UnobserveEntry unobserve_entry(
128 NULL, 132 NULL,
129 file_system_info_, 133 file_system_info_,
130 base::FilePath::FromUTF8Unsafe(kEntryPath), 134 base::FilePath::FromUTF8Unsafe(kEntryPath),
135 true /* recursive */,
131 base::Bind(&util::LogStatusCallback, &callback_log)); 136 base::Bind(&util::LogStatusCallback, &callback_log));
132 unobserve_entry.SetDispatchEventImplForTesting( 137 unobserve_entry.SetDispatchEventImplForTesting(
133 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 138 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
134 base::Unretained(&dispatcher))); 139 base::Unretained(&dispatcher)));
135 140
136 EXPECT_TRUE(unobserve_entry.Execute(kRequestId)); 141 EXPECT_TRUE(unobserve_entry.Execute(kRequestId));
137 142
138 unobserve_entry.OnError(kRequestId, 143 unobserve_entry.OnError(kRequestId,
139 scoped_ptr<RequestValue>(new RequestValue()), 144 scoped_ptr<RequestValue>(new RequestValue()),
140 base::File::FILE_ERROR_TOO_MANY_OPENED); 145 base::File::FILE_ERROR_TOO_MANY_OPENED);
141 ASSERT_EQ(1u, callback_log.size()); 146 ASSERT_EQ(1u, callback_log.size());
142 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); 147 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]);
143 } 148 }
144 149
145 } // namespace operations 150 } // namespace operations
146 } // namespace file_system_provider 151 } // namespace file_system_provider
147 } // namespace chromeos 152 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698