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

Side by Side Diff: chrome/browser/extensions/activity_log/counting_policy_unittest.cc

Issue 23991002: Fix flaky CountingPolicyTest.CapReturns test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // Submit a request to the policy to read back some data, and call the 80 // Submit a request to the policy to read back some data, and call the
81 // checker function when results are available. This will happen on the 81 // checker function when results are available. This will happen on the
82 // database thread. 82 // database thread.
83 policy->ReadData( 83 policy->ReadData(
84 extension_id, 84 extension_id,
85 day, 85 day,
86 base::Bind(&CountingPolicyTest::CheckWrapper, 86 base::Bind(&CountingPolicyTest::CheckWrapper,
87 checker, 87 checker,
88 base::MessageLoop::current()->QuitClosure())); 88 base::MessageLoop::current()->QuitClosure()));
89 89
90 // Set up a timeout that will trigger after 5 seconds; if we haven't 90 // Set up a timeout that will trigger after 8 seconds; if we haven't
91 // received any results by then assume that the test is broken. 91 // received any results by then assume that the test is broken.
92 base::CancelableClosure timeout( 92 base::CancelableClosure timeout(
93 base::Bind(&CountingPolicyTest::TimeoutCallback)); 93 base::Bind(&CountingPolicyTest::TimeoutCallback));
94 base::MessageLoop::current()->PostDelayedTask( 94 base::MessageLoop::current()->PostDelayedTask(
95 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(5)); 95 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(8));
96 96
97 // Wait for results; either the checker or the timeout callbacks should 97 // Wait for results; either the checker or the timeout callbacks should
98 // cause the main loop to exit. 98 // cause the main loop to exit.
99 base::MessageLoop::current()->Run(); 99 base::MessageLoop::current()->Run();
100 100
101 timeout.Cancel(); 101 timeout.Cancel();
102 } 102 }
103 103
104 // A helper function to call ReadFilteredData on a policy object and wait for 104 // A helper function to call ReadFilteredData on a policy object and wait for
105 // the results to be processed. 105 // the results to be processed.
(...skipping 11 matching lines...) Expand all
117 policy->ReadFilteredData( 117 policy->ReadFilteredData(
118 extension_id, 118 extension_id,
119 type, 119 type,
120 api_name, 120 api_name,
121 page_url, 121 page_url,
122 arg_url, 122 arg_url,
123 base::Bind(&CountingPolicyTest::CheckWrapper, 123 base::Bind(&CountingPolicyTest::CheckWrapper,
124 checker, 124 checker,
125 base::MessageLoop::current()->QuitClosure())); 125 base::MessageLoop::current()->QuitClosure()));
126 126
127 // Set up a timeout that will trigger after 5 seconds; if we haven't 127 // Set up a timeout that will trigger after 8 seconds; if we haven't
128 // received any results by then assume that the test is broken. 128 // received any results by then assume that the test is broken.
129 base::CancelableClosure timeout( 129 base::CancelableClosure timeout(
130 base::Bind(&CountingPolicyTest::TimeoutCallback)); 130 base::Bind(&CountingPolicyTest::TimeoutCallback));
131 base::MessageLoop::current()->PostDelayedTask( 131 base::MessageLoop::current()->PostDelayedTask(
132 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(5)); 132 FROM_HERE, timeout.callback(), base::TimeDelta::FromSeconds(8));
133 133
134 // Wait for results; either the checker or the timeout callbacks should 134 // Wait for results; either the checker or the timeout callbacks should
135 // cause the main loop to exit. 135 // cause the main loop to exit.
136 base::MessageLoop::current()->Run(); 136 base::MessageLoop::current()->Run();
137 137
138 timeout.Cancel(); 138 timeout.Cancel();
139 } 139 }
140 140
141 // A helper function which verifies that the string_ids and url_ids tables in 141 // A helper function which verifies that the string_ids and url_ids tables in
142 // the database have the specified sizes. 142 // the database have the specified sizes.
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 CountingPolicy* policy = new CountingPolicy(profile_.get()); 791 CountingPolicy* policy = new CountingPolicy(profile_.get());
792 792
793 for (int i = 0; i < 305; i++) { 793 for (int i = 0; i < 305; i++) {
794 scoped_refptr<Action> action = 794 scoped_refptr<Action> action =
795 new Action("punky", 795 new Action("punky",
796 base::Time::Now(), 796 base::Time::Now(),
797 Action::ACTION_API_CALL, 797 Action::ACTION_API_CALL,
798 base::StringPrintf("apicall_%d", i)); 798 base::StringPrintf("apicall_%d", i));
799 policy->ProcessAction(action); 799 policy->ProcessAction(action);
800 } 800 }
801
801 policy->Flush(); 802 policy->Flush();
803 WaitOnThread(BrowserThread::DB);
802 804
803 CheckReadFilteredData( 805 CheckReadFilteredData(
804 policy, 806 policy,
805 "punky", 807 "punky",
806 Action::ACTION_ANY, 808 Action::ACTION_ANY,
807 "", 809 "",
808 "", 810 "",
809 "", 811 "",
810 base::Bind( 812 base::Bind(
811 &CountingPolicyTest::RetrieveActions_FetchFilteredActions300)); 813 &CountingPolicyTest::RetrieveActions_FetchFilteredActions300));
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 925
924 CheckReadData( 926 CheckReadData(
925 policy, 927 policy,
926 "punky", 928 "punky",
927 0, 929 0,
928 base::Bind(&CountingPolicyTest::SomeURLsRemoved)); 930 base::Bind(&CountingPolicyTest::SomeURLsRemoved));
929 policy->Close(); 931 policy->Close();
930 } 932 }
931 933
932 } // namespace extensions 934 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698