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" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> |
6 | 9 |
7 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
8 #include "base/command_line.h" | 11 #include "base/command_line.h" |
9 #include "base/location.h" | 12 #include "base/location.h" |
10 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
11 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
12 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
14 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
15 #include "base/test/simple_test_clock.h" | 18 #include "base/test/simple_test_clock.h" |
16 #include "base/test/test_timeouts.h" | 19 #include "base/test/test_timeouts.h" |
17 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
18 #include "build/build_config.h" | 21 #include "build/build_config.h" |
19 #include "chrome/browser/extensions/activity_log/activity_log.h" | 22 #include "chrome/browser/extensions/activity_log/activity_log.h" |
20 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" | |
21 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
22 #include "chrome/browser/extensions/test_extension_system.h" | 24 #include "chrome/browser/extensions/test_extension_system.h" |
23 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
24 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 27 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
26 #include "chrome/test/base/testing_profile.h" | 28 #include "chrome/test/base/testing_profile.h" |
27 #include "content/public/test/test_browser_thread_bundle.h" | 29 #include "content/public/test/test_browser_thread_bundle.h" |
28 #include "extensions/common/extension_builder.h" | 30 #include "extensions/common/extension_builder.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
30 | 32 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // cause the main loop to exit. | 112 // cause the main loop to exit. |
111 base::MessageLoop::current()->Run(); | 113 base::MessageLoop::current()->Run(); |
112 | 114 |
113 timeout.Cancel(); | 115 timeout.Cancel(); |
114 } | 116 } |
115 | 117 |
116 static void CheckWrapper( | 118 static void CheckWrapper( |
117 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker, | 119 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker, |
118 const base::Closure& done, | 120 const base::Closure& done, |
119 scoped_ptr<Action::ActionVector> results) { | 121 scoped_ptr<Action::ActionVector> results) { |
120 checker.Run(results.Pass()); | 122 checker.Run(std::move(results)); |
121 done.Run(); | 123 done.Run(); |
122 } | 124 } |
123 | 125 |
124 static void TimeoutCallback() { | 126 static void TimeoutCallback() { |
125 base::MessageLoop::current()->QuitWhenIdle(); | 127 base::MessageLoop::current()->QuitWhenIdle(); |
126 FAIL() << "Policy test timed out waiting for results"; | 128 FAIL() << "Policy test timed out waiting for results"; |
127 } | 129 } |
128 | 130 |
129 static void RetrieveActions_LogAndFetchActions( | 131 static void RetrieveActions_LogAndFetchActions( |
130 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { | 132 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 .Set("name", "Test extension") | 461 .Set("name", "Test extension") |
460 .Set("version", "1.0.0") | 462 .Set("version", "1.0.0") |
461 .Set("manifest_version", 2))) | 463 .Set("manifest_version", 2))) |
462 .Build(); | 464 .Build(); |
463 extension_service_->AddExtension(extension.get()); | 465 extension_service_->AddExtension(extension.get()); |
464 scoped_ptr<base::ListValue> args(new base::ListValue()); | 466 scoped_ptr<base::ListValue> args(new base::ListValue()); |
465 scoped_refptr<Action> action = new Action(extension->id(), | 467 scoped_refptr<Action> action = new Action(extension->id(), |
466 base::Time::Now(), | 468 base::Time::Now(), |
467 Action::ACTION_API_CALL, | 469 Action::ACTION_API_CALL, |
468 "tabs.testMethod"); | 470 "tabs.testMethod"); |
469 action->set_args(args.Pass()); | 471 action->set_args(std::move(args)); |
470 policy->ProcessAction(action); | 472 policy->ProcessAction(action); |
471 policy->Close(); | 473 policy->Close(); |
472 } | 474 } |
473 | 475 |
474 TEST_F(FullStreamUIPolicyTest, LogAndFetchActions) { | 476 TEST_F(FullStreamUIPolicyTest, LogAndFetchActions) { |
475 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); | 477 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); |
476 policy->Init(); | 478 policy->Init(); |
477 scoped_refptr<const Extension> extension = | 479 scoped_refptr<const Extension> extension = |
478 ExtensionBuilder() | 480 ExtensionBuilder() |
479 .SetManifest(std::move(DictionaryBuilder() | 481 .SetManifest(std::move(DictionaryBuilder() |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 .Build(); | 621 .Build(); |
620 extension_service_->AddExtension(extension.get()); | 622 extension_service_->AddExtension(extension.get()); |
621 | 623 |
622 scoped_ptr<base::ListValue> args(new base::ListValue()); | 624 scoped_ptr<base::ListValue> args(new base::ListValue()); |
623 args->Set(0, new base::StringValue("hello")); | 625 args->Set(0, new base::StringValue("hello")); |
624 args->Set(1, new base::StringValue("world")); | 626 args->Set(1, new base::StringValue("world")); |
625 scoped_refptr<Action> action = new Action(extension->id(), | 627 scoped_refptr<Action> action = new Action(extension->id(), |
626 base::Time::Now(), | 628 base::Time::Now(), |
627 Action::ACTION_API_CALL, | 629 Action::ACTION_API_CALL, |
628 "extension.connect"); | 630 "extension.connect"); |
629 action->set_args(args.Pass()); | 631 action->set_args(std::move(args)); |
630 | 632 |
631 policy->ProcessAction(action); | 633 policy->ProcessAction(action); |
632 CheckReadData(policy, | 634 CheckReadData(policy, |
633 extension->id(), | 635 extension->id(), |
634 0, | 636 0, |
635 base::Bind(&FullStreamUIPolicyTest::Arguments_Present)); | 637 base::Bind(&FullStreamUIPolicyTest::Arguments_Present)); |
636 policy->Close(); | 638 policy->Close(); |
637 } | 639 } |
638 | 640 |
639 TEST_F(FullStreamUIPolicyTest, GetTodaysActions) { | 641 TEST_F(FullStreamUIPolicyTest, GetTodaysActions) { |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 action_ids.push_back(3); | 1050 action_ids.push_back(3); |
1049 action_ids.push_back(4); | 1051 action_ids.push_back(4); |
1050 CheckRemoveActions( | 1052 CheckRemoveActions( |
1051 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); | 1053 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); |
1052 action_ids.clear(); | 1054 action_ids.clear(); |
1053 | 1055 |
1054 policy->Close(); | 1056 policy->Close(); |
1055 } | 1057 } |
1056 | 1058 |
1057 } // namespace extensions | 1059 } // namespace extensions |
OLD | NEW |