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

Side by Side Diff: chrome/browser/geolocation/geolocation_permission_context_unittest.cc

Issue 409743003: Use content::RunBlockingPoolTask() in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/geolocation/geolocation_permission_context.h" 5 #include "chrome/browser/geolocation/geolocation_permission_context.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/id_map.h"
13 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
14 #include "base/run_loop.h"
15 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
16 #include "base/test/simple_test_clock.h" 16 #include "base/test/simple_test_clock.h"
17 #include "base/time/clock.h" 17 #include "base/time/clock.h"
18 #include "chrome/browser/chrome_notification_types.h" 18 #include "chrome/browser/chrome_notification_types.h"
19 #include "chrome/browser/content_settings/host_content_settings_map.h" 19 #include "chrome/browser/content_settings/host_content_settings_map.h"
20 #include "chrome/browser/content_settings/permission_request_id.h" 20 #include "chrome/browser/content_settings/permission_request_id.h"
21 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 21 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
22 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" 22 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
23 #include "chrome/browser/infobars/infobar_service.h" 23 #include "chrome/browser/infobars/infobar_service.h"
24 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 24 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
25 #include "chrome/test/base/testing_profile.h" 25 #include "chrome/test/base/testing_profile.h"
26 #include "components/infobars/core/confirm_infobar_delegate.h" 26 #include "components/infobars/core/confirm_infobar_delegate.h"
27 #include "components/infobars/core/infobar.h" 27 #include "components/infobars/core/infobar.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/navigation_details.h" 29 #include "content/public/browser/navigation_details.h"
30 #include "content/public/browser/notification_registrar.h" 30 #include "content/public/browser/notification_registrar.h"
31 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
32 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
33 #include "content/public/test/mock_render_process_host.h" 33 #include "content/public/test/mock_render_process_host.h"
34 #include "content/public/test/test_renderer_host.h" 34 #include "content/public/test/test_renderer_host.h"
35 #include "content/public/test/test_utils.h"
35 #include "content/public/test/web_contents_tester.h" 36 #include "content/public/test/web_contents_tester.h"
36 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
37 38
38 #if defined(OS_ANDROID) 39 #if defined(OS_ANDROID)
39 #include "base/prefs/pref_service.h" 40 #include "base/prefs/pref_service.h"
40 #include "chrome/browser/android/mock_google_location_settings_helper.h" 41 #include "chrome/browser/android/mock_google_location_settings_helper.h"
41 #include "chrome/common/pref_names.h" 42 #include "chrome/common/pref_names.h"
42 #endif 43 #endif
43 44
44 #if defined(ENABLE_EXTENSIONS) 45 #if defined(ENABLE_EXTENSIONS)
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void GeolocationPermissionContextTests::RequestGeolocationPermission( 173 void GeolocationPermissionContextTests::RequestGeolocationPermission(
173 content::WebContents* web_contents, 174 content::WebContents* web_contents,
174 const PermissionRequestID& id, 175 const PermissionRequestID& id,
175 const GURL& requesting_frame, 176 const GURL& requesting_frame,
176 base::Closure* cancel_callback) { 177 base::Closure* cancel_callback) {
177 geolocation_permission_context_->RequestGeolocationPermission( 178 geolocation_permission_context_->RequestGeolocationPermission(
178 web_contents, id.bridge_id(), requesting_frame, false, 179 web_contents, id.bridge_id(), requesting_frame, false,
179 base::Bind(&GeolocationPermissionContextTests::PermissionResponse, 180 base::Bind(&GeolocationPermissionContextTests::PermissionResponse,
180 base::Unretained(this), id), 181 base::Unretained(this), id),
181 cancel_callback); 182 cancel_callback);
182 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 183 content::RunAllBlockingPoolTasksUntilIdle();
183 base::RunLoop().RunUntilIdle();
184 } 184 }
185 185
186 void GeolocationPermissionContextTests::PermissionResponse( 186 void GeolocationPermissionContextTests::PermissionResponse(
187 const PermissionRequestID& id, 187 const PermissionRequestID& id,
188 bool allowed) { 188 bool allowed) {
189 responses_[id.render_process_id()] = std::make_pair(id.bridge_id(), allowed); 189 responses_[id.render_process_id()] = std::make_pair(id.bridge_id(), allowed);
190 } 190 }
191 191
192 void GeolocationPermissionContextTests::CheckPermissionMessageSent( 192 void GeolocationPermissionContextTests::CheckPermissionMessageSent(
193 int bridge_id, 193 int bridge_id,
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 // it is the embedder. 815 // it is the embedder.
816 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), 816 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(),
817 requesting_frame_0.GetOrigin(), 817 requesting_frame_0.GetOrigin(),
818 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 818 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
819 13); 819 13);
820 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), 820 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(),
821 requesting_frame_0.GetOrigin(), 821 requesting_frame_0.GetOrigin(),
822 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 822 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(),
823 11); 823 11);
824 } 824 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698