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/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
10 #include "base/test/simple_test_clock.h" | 11 #include "base/test/simple_test_clock.h" |
11 #include "chrome/browser/extensions/activity_log/activity_log.h" | 12 #include "chrome/browser/extensions/activity_log/activity_log.h" |
12 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" | 13 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/extensions/test_extension_system.h" | 15 #include "chrome/browser/extensions/test_extension_system.h" |
15 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/extensions/extension_builder.h" | 18 #include "chrome/common/extensions/extension_builder.h" |
18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 static void RetrieveActions_FetchFilteredActions1( | 150 static void RetrieveActions_FetchFilteredActions1( |
150 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { | 151 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { |
151 ASSERT_EQ(1, static_cast<int>(i->size())); | 152 ASSERT_EQ(1, static_cast<int>(i->size())); |
152 } | 153 } |
153 | 154 |
154 static void RetrieveActions_FetchFilteredActions2( | 155 static void RetrieveActions_FetchFilteredActions2( |
155 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { | 156 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { |
156 ASSERT_EQ(2, static_cast<int>(i->size())); | 157 ASSERT_EQ(2, static_cast<int>(i->size())); |
157 } | 158 } |
158 | 159 |
| 160 static void RetrieveActions_FetchFilteredActions300( |
| 161 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { |
| 162 ASSERT_EQ(300, static_cast<int>(i->size())); |
| 163 } |
| 164 |
159 static void Arguments_Present(scoped_ptr<Action::ActionVector> i) { | 165 static void Arguments_Present(scoped_ptr<Action::ActionVector> i) { |
160 scoped_refptr<Action> last = i->front(); | 166 scoped_refptr<Action> last = i->front(); |
161 std::string args = | 167 std::string args = |
162 "ID=odlameecjipmbmbejkplpemijjgpljce CATEGORY=api_call " | 168 "ID=odlameecjipmbmbejkplpemijjgpljce CATEGORY=api_call " |
163 "API=extension.connect ARGS=[\"hello\",\"world\"]"; | 169 "API=extension.connect ARGS=[\"hello\",\"world\"]"; |
164 ASSERT_EQ(args, last->PrintForDebug()); | 170 ASSERT_EQ(args, last->PrintForDebug()); |
165 } | 171 } |
166 | 172 |
167 static void Arguments_GetTodaysActions( | 173 static void Arguments_GetTodaysActions( |
168 scoped_ptr<Action::ActionVector> actions) { | 174 scoped_ptr<Action::ActionVector> actions) { |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 policy->RemoveURLs(urls); | 641 policy->RemoveURLs(urls); |
636 | 642 |
637 CheckReadData( | 643 CheckReadData( |
638 policy, | 644 policy, |
639 "punky", | 645 "punky", |
640 0, | 646 0, |
641 base::Bind(&FullStreamUIPolicyTest::SomeURLsRemoved)); | 647 base::Bind(&FullStreamUIPolicyTest::SomeURLsRemoved)); |
642 policy->Close(); | 648 policy->Close(); |
643 } | 649 } |
644 | 650 |
| 651 TEST_F(FullStreamUIPolicyTest, CapReturns) { |
| 652 FullStreamUIPolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 653 |
| 654 for (int i = 0; i < 305; i++) { |
| 655 scoped_refptr<Action> action = |
| 656 new Action("punky", |
| 657 base::Time::Now(), |
| 658 Action::ACTION_API_CALL, |
| 659 base::StringPrintf("apicall_%d", i)); |
| 660 policy->ProcessAction(action); |
| 661 } |
| 662 policy->Flush(); |
| 663 |
| 664 CheckReadFilteredData( |
| 665 policy, |
| 666 "punky", |
| 667 Action::ACTION_ANY, |
| 668 "", |
| 669 "", |
| 670 "", |
| 671 base::Bind( |
| 672 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions300)); |
| 673 policy->Close(); |
| 674 } |
| 675 |
645 } // namespace extensions | 676 } // namespace extensions |
OLD | NEW |