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

Side by Side Diff: chrome/browser/chromeos/policy/device_status_collector_browsertest.cc

Issue 2192683003: Revert of Reland: Geolocation: move from content/browser to device/ (patchset #2 id:20001 of https:… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2810
Patch Set: Created 4 years, 4 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
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/chromeos/policy/device_status_collector.h" 5 #include "chrome/browser/chromeos/policy/device_status_collector.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "chromeos/disks/disk_mount_manager.h" 44 #include "chromeos/disks/disk_mount_manager.h"
45 #include "chromeos/disks/mock_disk_mount_manager.h" 45 #include "chromeos/disks/mock_disk_mount_manager.h"
46 #include "chromeos/network/network_handler.h" 46 #include "chromeos/network/network_handler.h"
47 #include "chromeos/network/network_state.h" 47 #include "chromeos/network/network_state.h"
48 #include "chromeos/network/network_state_handler.h" 48 #include "chromeos/network/network_state_handler.h"
49 #include "chromeos/settings/cros_settings_names.h" 49 #include "chromeos/settings/cros_settings_names.h"
50 #include "chromeos/system/fake_statistics_provider.h" 50 #include "chromeos/system/fake_statistics_provider.h"
51 #include "components/prefs/pref_service.h" 51 #include "components/prefs/pref_service.h"
52 #include "components/prefs/testing_pref_service.h" 52 #include "components/prefs/testing_pref_service.h"
53 #include "content/public/browser/browser_thread.h" 53 #include "content/public/browser/browser_thread.h"
54 #include "content/public/browser/geolocation_provider.h"
54 #include "content/public/test/test_browser_thread.h" 55 #include "content/public/test/test_browser_thread.h"
55 #include "content/public/test/test_utils.h" 56 #include "content/public/test/test_utils.h"
56 #include "device/geolocation/geolocation_provider.h"
57 #include "policy/proto/device_management_backend.pb.h" 57 #include "policy/proto/device_management_backend.pb.h"
58 #include "storage/browser/fileapi/external_mount_points.h" 58 #include "storage/browser/fileapi/external_mount_points.h"
59 #include "storage/browser/fileapi/mount_points.h" 59 #include "storage/browser/fileapi/mount_points.h"
60 #include "storage/common/fileapi/file_system_mount_option.h" 60 #include "storage/common/fileapi/file_system_mount_option.h"
61 #include "storage/common/fileapi/file_system_types.h" 61 #include "storage/common/fileapi/file_system_types.h"
62 #include "testing/gmock/include/gmock/gmock.h" 62 #include "testing/gmock/include/gmock/gmock.h"
63 #include "testing/gtest/include/gtest/gtest.h" 63 #include "testing/gtest/include/gtest/gtest.h"
64 #include "third_party/cros_system_api/dbus/service_constants.h" 64 #include "third_party/cros_system_api/dbus/service_constants.h"
65 65
66 using ::testing::Return; 66 using ::testing::Return;
67 using ::testing::ReturnRef; 67 using ::testing::ReturnRef;
68 using base::Time; 68 using base::Time;
69 using base::TimeDelta; 69 using base::TimeDelta;
70 using chromeos::disks::DiskMountManager; 70 using chromeos::disks::DiskMountManager;
71 71
72 namespace em = enterprise_management; 72 namespace em = enterprise_management;
73 73
74 namespace { 74 namespace {
75 75
76 const int64_t kMillisecondsPerDay = Time::kMicrosecondsPerDay / 1000; 76 const int64_t kMillisecondsPerDay = Time::kMicrosecondsPerDay / 1000;
77 const char kKioskAccountId[] = "kiosk_user@localhost"; 77 const char kKioskAccountId[] = "kiosk_user@localhost";
78 const char kKioskAppId[] = "kiosk_app_id"; 78 const char kKioskAppId[] = "kiosk_app_id";
79 const char kExternalMountPoint[] = "/a/b/c"; 79 const char kExternalMountPoint[] = "/a/b/c";
80 const char kPublicAccountId[] = "public_user@localhost"; 80 const char kPublicAccountId[] = "public_user@localhost";
81 81
82 std::unique_ptr<device::Geoposition> mock_position_to_return_next; 82 std::unique_ptr<content::Geoposition> mock_position_to_return_next;
83 83
84 void SetMockPositionToReturnNext(const device::Geoposition& position) { 84 void SetMockPositionToReturnNext(const content::Geoposition &position) {
85 mock_position_to_return_next.reset(new device::Geoposition(position)); 85 mock_position_to_return_next.reset(new content::Geoposition(position));
86 } 86 }
87 87
88 void MockPositionUpdateRequester( 88 void MockPositionUpdateRequester(
89 const device::GeolocationProvider::LocationUpdateCallback& callback) { 89 const content::GeolocationProvider::LocationUpdateCallback& callback) {
90 if (!mock_position_to_return_next.get()) 90 if (!mock_position_to_return_next.get())
91 return; 91 return;
92 92
93 // If the fix is invalid, the DeviceStatusCollector will immediately request 93 // If the fix is invalid, the DeviceStatusCollector will immediately request
94 // another update when it receives the callback. This is desirable and safe in 94 // another update when it receives the callback. This is desirable and safe in
95 // real life where geolocation updates arrive asynchronously. In this testing 95 // real life where geolocation updates arrive asynchronously. In this testing
96 // harness, the callback is invoked synchronously upon request, leading to a 96 // harness, the callback is invoked synchronously upon request, leading to a
97 // request-callback loop. The loop is broken by returning the mock position 97 // request-callback loop. The loop is broken by returning the mock position
98 // only once. 98 // only once.
99 std::unique_ptr<device::Geoposition> position( 99 std::unique_ptr<content::Geoposition> position(
100 mock_position_to_return_next.release()); 100 mock_position_to_return_next.release());
101 callback.Run(*position); 101 callback.Run(*position);
102 } 102 }
103 103
104 class TestingDeviceStatusCollector : public policy::DeviceStatusCollector { 104 class TestingDeviceStatusCollector : public policy::DeviceStatusCollector {
105 public: 105 public:
106 TestingDeviceStatusCollector( 106 TestingDeviceStatusCollector(
107 PrefService* local_state, 107 PrefService* local_state,
108 chromeos::system::StatisticsProvider* provider, 108 chromeos::system::StatisticsProvider* provider,
109 const policy::DeviceStatusCollector::LocationUpdateRequester& 109 const policy::DeviceStatusCollector::LocationUpdateRequester&
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 EXPECT_TRUE(status_.has_os_version()); 780 EXPECT_TRUE(status_.has_os_version());
781 EXPECT_TRUE(status_.has_firmware_version()); 781 EXPECT_TRUE(status_.has_firmware_version());
782 782
783 // Check that the browser version is not empty. OS version & firmware 783 // Check that the browser version is not empty. OS version & firmware
784 // don't have any reasonable values inside the unit test, so those 784 // don't have any reasonable values inside the unit test, so those
785 // aren't checked. 785 // aren't checked.
786 EXPECT_NE("", status_.browser_version()); 786 EXPECT_NE("", status_.browser_version());
787 } 787 }
788 788
789 TEST_F(DeviceStatusCollectorTest, Location) { 789 TEST_F(DeviceStatusCollectorTest, Location) {
790 device::Geoposition valid_fix; 790 content::Geoposition valid_fix;
791 valid_fix.latitude = 4.3; 791 valid_fix.latitude = 4.3;
792 valid_fix.longitude = -7.8; 792 valid_fix.longitude = -7.8;
793 valid_fix.accuracy = 3.; 793 valid_fix.accuracy = 3.;
794 valid_fix.timestamp = Time::Now(); 794 valid_fix.timestamp = Time::Now();
795 795
796 device::Geoposition invalid_fix; 796 content::Geoposition invalid_fix;
797 invalid_fix.error_code = device::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; 797 invalid_fix.error_code =
798 content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
798 invalid_fix.timestamp = Time::Now(); 799 invalid_fix.timestamp = Time::Now();
799 800
800 // Check that when device location reporting is disabled, no location is 801 // Check that when device location reporting is disabled, no location is
801 // reported. 802 // reported.
802 SetMockPositionToReturnNext(valid_fix); 803 SetMockPositionToReturnNext(valid_fix);
803 CheckThatNoLocationIsReported(); 804 CheckThatNoLocationIsReported();
804 805
805 // Check that when device location reporting is enabled and a valid fix is 806 // Check that when device location reporting is enabled and a valid fix is
806 // available, the location is reported and is stored in local state. 807 // available, the location is reported and is stored in local state.
807 SetMockPositionToReturnNext(valid_fix); 808 SetMockPositionToReturnNext(valid_fix);
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 AccountId::FromUserEmail(kPublicAccountId)); 1487 AccountId::FromUserEmail(kPublicAccountId));
1487 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) 1488 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount())
1488 .WillRepeatedly(Return(true)); 1489 .WillRepeatedly(Return(true));
1489 1490
1490 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); 1491 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true);
1491 GetStatus(); 1492 GetStatus();
1492 VerifyNetworkReporting(); 1493 VerifyNetworkReporting();
1493 } 1494 }
1494 1495
1495 } // namespace policy 1496 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698