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