| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/cancelable_callback.h" | 5 #include "base/cancelable_callback.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 ASSERT_EQ(2, static_cast<int>(i->size())); | 147 ASSERT_EQ(2, static_cast<int>(i->size())); |
| 148 } | 148 } |
| 149 | 149 |
| 150 static void RetrieveActions_FetchFilteredActions300( | 150 static void RetrieveActions_FetchFilteredActions300( |
| 151 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { | 151 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { |
| 152 ASSERT_EQ(300, static_cast<int>(i->size())); | 152 ASSERT_EQ(300, static_cast<int>(i->size())); |
| 153 } | 153 } |
| 154 | 154 |
| 155 static void Arguments_Present(scoped_ptr<Action::ActionVector> i) { | 155 static void Arguments_Present(scoped_ptr<Action::ActionVector> i) { |
| 156 scoped_refptr<Action> last = i->front(); | 156 scoped_refptr<Action> last = i->front(); |
| 157 CheckAction(*last, "odlameecjipmbmbejkplpemijjgpljce", | 157 CheckAction(*last.get(), |
| 158 Action::ACTION_API_CALL, "extension.connect", | 158 "odlameecjipmbmbejkplpemijjgpljce", |
| 159 "[\"hello\",\"world\"]", "", "", ""); | 159 Action::ACTION_API_CALL, |
| 160 "extension.connect", |
| 161 "[\"hello\",\"world\"]", |
| 162 "", |
| 163 "", |
| 164 ""); |
| 160 } | 165 } |
| 161 | 166 |
| 162 static void Arguments_GetTodaysActions( | 167 static void Arguments_GetTodaysActions( |
| 163 scoped_ptr<Action::ActionVector> actions) { | 168 scoped_ptr<Action::ActionVector> actions) { |
| 164 ASSERT_EQ(2, static_cast<int>(actions->size())); | 169 ASSERT_EQ(2, static_cast<int>(actions->size())); |
| 165 CheckAction(*actions->at(0), "punky", Action::ACTION_DOM_ACCESS, "lets", | 170 CheckAction(*actions->at(0).get(), |
| 166 "[\"vamoose\"]", "http://www.google.com/", "Page Title", | 171 "punky", |
| 172 Action::ACTION_DOM_ACCESS, |
| 173 "lets", |
| 174 "[\"vamoose\"]", |
| 175 "http://www.google.com/", |
| 176 "Page Title", |
| 167 "http://www.arg-url.com/"); | 177 "http://www.arg-url.com/"); |
| 168 CheckAction(*actions->at(1), "punky", Action::ACTION_API_CALL, "brewster", | 178 CheckAction(*actions->at(1).get(), |
| 169 "[\"woof\"]", "", "Page Title", "http://www.arg-url.com/"); | 179 "punky", |
| 180 Action::ACTION_API_CALL, |
| 181 "brewster", |
| 182 "[\"woof\"]", |
| 183 "", |
| 184 "Page Title", |
| 185 "http://www.arg-url.com/"); |
| 170 } | 186 } |
| 171 | 187 |
| 172 static void Arguments_GetOlderActions( | 188 static void Arguments_GetOlderActions( |
| 173 scoped_ptr<Action::ActionVector> actions) { | 189 scoped_ptr<Action::ActionVector> actions) { |
| 174 ASSERT_EQ(2, static_cast<int>(actions->size())); | 190 ASSERT_EQ(2, static_cast<int>(actions->size())); |
| 175 CheckAction(*actions->at(0), "punky", Action::ACTION_DOM_ACCESS, "lets", | 191 CheckAction(*actions->at(0).get(), |
| 176 "[\"vamoose\"]", "http://www.google.com/", "", ""); | 192 "punky", |
| 177 CheckAction(*actions->at(1), "punky", Action::ACTION_API_CALL, "brewster", | 193 Action::ACTION_DOM_ACCESS, |
| 178 "[\"woof\"]", "", "", ""); | 194 "lets", |
| 195 "[\"vamoose\"]", |
| 196 "http://www.google.com/", |
| 197 "", |
| 198 ""); |
| 199 CheckAction(*actions->at(1).get(), |
| 200 "punky", |
| 201 Action::ACTION_API_CALL, |
| 202 "brewster", |
| 203 "[\"woof\"]", |
| 204 "", |
| 205 "", |
| 206 ""); |
| 179 } | 207 } |
| 180 | 208 |
| 181 static void AllURLsRemoved(scoped_ptr<Action::ActionVector> actions) { | 209 static void AllURLsRemoved(scoped_ptr<Action::ActionVector> actions) { |
| 182 ASSERT_EQ(2, static_cast<int>(actions->size())); | 210 ASSERT_EQ(2, static_cast<int>(actions->size())); |
| 183 CheckAction(*actions->at(0), "punky", Action::ACTION_API_CALL, "lets", | 211 CheckAction(*actions->at(0).get(), |
| 184 "[\"vamoose\"]", "", "", ""); | 212 "punky", |
| 185 CheckAction(*actions->at(1), "punky", Action::ACTION_DOM_ACCESS, "lets", | 213 Action::ACTION_API_CALL, |
| 186 "[\"vamoose\"]", "", "", ""); | 214 "lets", |
| 215 "[\"vamoose\"]", |
| 216 "", |
| 217 "", |
| 218 ""); |
| 219 CheckAction(*actions->at(1).get(), |
| 220 "punky", |
| 221 Action::ACTION_DOM_ACCESS, |
| 222 "lets", |
| 223 "[\"vamoose\"]", |
| 224 "", |
| 225 "", |
| 226 ""); |
| 187 } | 227 } |
| 188 | 228 |
| 189 static void SomeURLsRemoved(scoped_ptr<Action::ActionVector> actions) { | 229 static void SomeURLsRemoved(scoped_ptr<Action::ActionVector> actions) { |
| 190 // These will be in the vector in reverse time order. | 230 // These will be in the vector in reverse time order. |
| 191 ASSERT_EQ(5, static_cast<int>(actions->size())); | 231 ASSERT_EQ(5, static_cast<int>(actions->size())); |
| 192 CheckAction(*actions->at(0), "punky", Action::ACTION_DOM_ACCESS, "lets", | 232 CheckAction(*actions->at(0).get(), |
| 193 "[\"vamoose\"]", "http://www.google.com/", "Google", | 233 "punky", |
| 234 Action::ACTION_DOM_ACCESS, |
| 235 "lets", |
| 236 "[\"vamoose\"]", |
| 237 "http://www.google.com/", |
| 238 "Google", |
| 194 "http://www.args-url.com/"); | 239 "http://www.args-url.com/"); |
| 195 CheckAction(*actions->at(1), "punky", Action::ACTION_DOM_ACCESS, "lets", | 240 CheckAction(*actions->at(1).get(), |
| 196 "[\"vamoose\"]", "http://www.google.com/", "Google", ""); | 241 "punky", |
| 197 CheckAction(*actions->at(2), "punky", Action::ACTION_DOM_ACCESS, "lets", | 242 Action::ACTION_DOM_ACCESS, |
| 198 "[\"vamoose\"]", "", "", ""); | 243 "lets", |
| 199 CheckAction(*actions->at(3), "punky", Action::ACTION_DOM_ACCESS, "lets", | 244 "[\"vamoose\"]", |
| 200 "[\"vamoose\"]", "", "", "http://www.google.com/"); | 245 "http://www.google.com/", |
| 201 CheckAction(*actions->at(4), "punky", Action::ACTION_DOM_ACCESS, "lets", | 246 "Google", |
| 202 "[\"vamoose\"]", "", "", ""); | 247 ""); |
| 248 CheckAction(*actions->at(2).get(), |
| 249 "punky", |
| 250 Action::ACTION_DOM_ACCESS, |
| 251 "lets", |
| 252 "[\"vamoose\"]", |
| 253 "", |
| 254 "", |
| 255 ""); |
| 256 CheckAction(*actions->at(3).get(), |
| 257 "punky", |
| 258 Action::ACTION_DOM_ACCESS, |
| 259 "lets", |
| 260 "[\"vamoose\"]", |
| 261 "", |
| 262 "", |
| 263 "http://www.google.com/"); |
| 264 CheckAction(*actions->at(4).get(), |
| 265 "punky", |
| 266 Action::ACTION_DOM_ACCESS, |
| 267 "lets", |
| 268 "[\"vamoose\"]", |
| 269 "", |
| 270 "", |
| 271 ""); |
| 203 } | 272 } |
| 204 | 273 |
| 205 static void CheckAction(const Action& action, | 274 static void CheckAction(const Action& action, |
| 206 const std::string& expected_id, | 275 const std::string& expected_id, |
| 207 const Action::ActionType& expected_type, | 276 const Action::ActionType& expected_type, |
| 208 const std::string& expected_api_name, | 277 const std::string& expected_api_name, |
| 209 const std::string& expected_args_str, | 278 const std::string& expected_args_str, |
| 210 const std::string& expected_page_url, | 279 const std::string& expected_page_url, |
| 211 const std::string& expected_page_title, | 280 const std::string& expected_page_title, |
| 212 const std::string& expected_arg_url) { | 281 const std::string& expected_arg_url) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 policy->DeleteDatabase(); | 344 policy->DeleteDatabase(); |
| 276 } | 345 } |
| 277 | 346 |
| 278 static void AllActionsDeleted(scoped_ptr<Action::ActionVector> actions) { | 347 static void AllActionsDeleted(scoped_ptr<Action::ActionVector> actions) { |
| 279 ASSERT_EQ(0, static_cast<int>(actions->size())); | 348 ASSERT_EQ(0, static_cast<int>(actions->size())); |
| 280 } | 349 } |
| 281 | 350 |
| 282 static void NoActionsDeleted(scoped_ptr<Action::ActionVector> actions) { | 351 static void NoActionsDeleted(scoped_ptr<Action::ActionVector> actions) { |
| 283 // These will be in the vector in reverse time order. | 352 // These will be in the vector in reverse time order. |
| 284 ASSERT_EQ(4, static_cast<int>(actions->size())); | 353 ASSERT_EQ(4, static_cast<int>(actions->size())); |
| 285 CheckAction(*actions->at(0), | 354 CheckAction(*actions->at(0).get(), |
| 286 "punky2", | 355 "punky2", |
| 287 Action::ACTION_API_CALL, | 356 Action::ACTION_API_CALL, |
| 288 "lets2", | 357 "lets2", |
| 289 "[\"vamoose2\"]", | 358 "[\"vamoose2\"]", |
| 290 "http://www.google2.com/", | 359 "http://www.google2.com/", |
| 291 "Google2", | 360 "Google2", |
| 292 "http://www.args-url2.com/"); | 361 "http://www.args-url2.com/"); |
| 293 ASSERT_EQ(3, actions->at(0)->action_id()); | 362 ASSERT_EQ(3, actions->at(0)->action_id()); |
| 294 CheckAction(*actions->at(1), | 363 CheckAction(*actions->at(1).get(), |
| 295 "punky2", | 364 "punky2", |
| 296 Action::ACTION_API_CALL, | 365 Action::ACTION_API_CALL, |
| 297 "lets2", | 366 "lets2", |
| 298 "[\"vamoose2\"]", | 367 "[\"vamoose2\"]", |
| 299 "http://www.google2.com/", | 368 "http://www.google2.com/", |
| 300 "Google2", | 369 "Google2", |
| 301 "http://www.args-url2.com/"); | 370 "http://www.args-url2.com/"); |
| 302 ASSERT_EQ(4, actions->at(1)->action_id()); | 371 ASSERT_EQ(4, actions->at(1)->action_id()); |
| 303 CheckAction(*actions->at(2), | 372 CheckAction(*actions->at(2).get(), |
| 304 "punky1", | 373 "punky1", |
| 305 Action::ACTION_DOM_ACCESS, | 374 Action::ACTION_DOM_ACCESS, |
| 306 "lets1", | 375 "lets1", |
| 307 "[\"vamoose1\"]", | 376 "[\"vamoose1\"]", |
| 308 "http://www.google1.com/", | 377 "http://www.google1.com/", |
| 309 "Google1", | 378 "Google1", |
| 310 "http://www.args-url1.com/"); | 379 "http://www.args-url1.com/"); |
| 311 ASSERT_EQ(1, actions->at(2)->action_id()); | 380 ASSERT_EQ(1, actions->at(2)->action_id()); |
| 312 CheckAction(*actions->at(3), | 381 CheckAction(*actions->at(3).get(), |
| 313 "punky1", | 382 "punky1", |
| 314 Action::ACTION_DOM_ACCESS, | 383 Action::ACTION_DOM_ACCESS, |
| 315 "lets1", | 384 "lets1", |
| 316 "[\"vamoose1\"]", | 385 "[\"vamoose1\"]", |
| 317 "http://www.google1.com/", | 386 "http://www.google1.com/", |
| 318 "Google1", | 387 "Google1", |
| 319 "http://www.args-url1.com/"); | 388 "http://www.args-url1.com/"); |
| 320 ASSERT_EQ(2, actions->at(3)->action_id()); | 389 ASSERT_EQ(2, actions->at(3)->action_id()); |
| 321 } | 390 } |
| 322 | 391 |
| 323 static void Action1Deleted(scoped_ptr<Action::ActionVector> actions) { | 392 static void Action1Deleted(scoped_ptr<Action::ActionVector> actions) { |
| 324 // These will be in the vector in reverse time order. | 393 // These will be in the vector in reverse time order. |
| 325 ASSERT_EQ(2, static_cast<int>(actions->size())); | 394 ASSERT_EQ(2, static_cast<int>(actions->size())); |
| 326 CheckAction(*actions->at(0), | 395 CheckAction(*actions->at(0).get(), |
| 327 "punky2", | 396 "punky2", |
| 328 Action::ACTION_API_CALL, | 397 Action::ACTION_API_CALL, |
| 329 "lets2", | 398 "lets2", |
| 330 "[\"vamoose2\"]", | 399 "[\"vamoose2\"]", |
| 331 "http://www.google2.com/", | 400 "http://www.google2.com/", |
| 332 "Google2", | 401 "Google2", |
| 333 "http://www.args-url2.com/"); | 402 "http://www.args-url2.com/"); |
| 334 ASSERT_EQ(3, actions->at(0)->action_id()); | 403 ASSERT_EQ(3, actions->at(0)->action_id()); |
| 335 CheckAction(*actions->at(1), | 404 CheckAction(*actions->at(1).get(), |
| 336 "punky2", | 405 "punky2", |
| 337 Action::ACTION_API_CALL, | 406 Action::ACTION_API_CALL, |
| 338 "lets2", | 407 "lets2", |
| 339 "[\"vamoose2\"]", | 408 "[\"vamoose2\"]", |
| 340 "http://www.google2.com/", | 409 "http://www.google2.com/", |
| 341 "Google2", | 410 "Google2", |
| 342 "http://www.args-url2.com/"); | 411 "http://www.args-url2.com/"); |
| 343 ASSERT_EQ(4, actions->at(1)->action_id()); | 412 ASSERT_EQ(4, actions->at(1)->action_id()); |
| 344 } | 413 } |
| 345 | 414 |
| 346 static void Action2Deleted(scoped_ptr<Action::ActionVector> actions) { | 415 static void Action2Deleted(scoped_ptr<Action::ActionVector> actions) { |
| 347 // These will be in the vector in reverse time order. | 416 // These will be in the vector in reverse time order. |
| 348 ASSERT_EQ(2, static_cast<int>(actions->size())); | 417 ASSERT_EQ(2, static_cast<int>(actions->size())); |
| 349 CheckAction(*actions->at(0), | 418 CheckAction(*actions->at(0).get(), |
| 350 "punky1", | 419 "punky1", |
| 351 Action::ACTION_DOM_ACCESS, | 420 Action::ACTION_DOM_ACCESS, |
| 352 "lets1", | 421 "lets1", |
| 353 "[\"vamoose1\"]", | 422 "[\"vamoose1\"]", |
| 354 "http://www.google1.com/", | 423 "http://www.google1.com/", |
| 355 "Google1", | 424 "Google1", |
| 356 "http://www.args-url1.com/"); | 425 "http://www.args-url1.com/"); |
| 357 ASSERT_EQ(1, actions->at(0)->action_id()); | 426 ASSERT_EQ(1, actions->at(0)->action_id()); |
| 358 CheckAction(*actions->at(1), | 427 CheckAction(*actions->at(1).get(), |
| 359 "punky1", | 428 "punky1", |
| 360 Action::ACTION_DOM_ACCESS, | 429 Action::ACTION_DOM_ACCESS, |
| 361 "lets1", | 430 "lets1", |
| 362 "[\"vamoose1\"]", | 431 "[\"vamoose1\"]", |
| 363 "http://www.google1.com/", | 432 "http://www.google1.com/", |
| 364 "Google1", | 433 "Google1", |
| 365 "http://www.args-url1.com/"); | 434 "http://www.args-url1.com/"); |
| 366 ASSERT_EQ(2, actions->at(1)->action_id()); | 435 ASSERT_EQ(2, actions->at(1)->action_id()); |
| 367 } | 436 } |
| 368 | 437 |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 action_ids.push_back(3); | 1052 action_ids.push_back(3); |
| 984 action_ids.push_back(4); | 1053 action_ids.push_back(4); |
| 985 CheckRemoveActions( | 1054 CheckRemoveActions( |
| 986 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); | 1055 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); |
| 987 action_ids.clear(); | 1056 action_ids.clear(); |
| 988 | 1057 |
| 989 policy->Close(); | 1058 policy->Close(); |
| 990 } | 1059 } |
| 991 | 1060 |
| 992 } // namespace extensions | 1061 } // namespace extensions |
| OLD | NEW |