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

Side by Side Diff: components/gcm_driver/gcm_client_impl_unittest.cc

Issue 2471433003: [GCM] Update ResetStore histograms (Closed)
Patch Set: Mark old histo as obsolete Created 4 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/gcm_driver/gcm_client_impl.h" 5 #include "components/gcm_driver/gcm_client_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <initializer_list> 9 #include <initializer_list>
10 #include <memory> 10 #include <memory>
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 gcm_client()->Stop(); 682 gcm_client()->Stop();
683 PumpLoopUntilIdle(); 683 PumpLoopUntilIdle();
684 684
685 // Mess up the store. 685 // Mess up the store.
686 base::FilePath store_file_path = 686 base::FilePath store_file_path =
687 gcm_store_path().Append(FILE_PATH_LITERAL("CURRENT")); 687 gcm_store_path().Append(FILE_PATH_LITERAL("CURRENT"));
688 ASSERT_TRUE(base::AppendToFile(store_file_path, "A", 1)); 688 ASSERT_TRUE(base::AppendToFile(store_file_path, "A", 1));
689 689
690 // Restart GCM client. The store should be reset and the loading should 690 // Restart GCM client. The store should be reset and the loading should
691 // complete successfully. 691 // complete successfully.
692
693 base::HistogramTester histogram_tester;
692 reset_last_event(); 694 reset_last_event();
693 BuildGCMClient(base::TimeDelta()); 695 BuildGCMClient(base::TimeDelta());
694 InitializeGCMClient(); 696 InitializeGCMClient();
695 StartGCMClient(); 697 StartGCMClient();
698 histogram_tester.ExpectUniqueSample("GCM.ResetStoreReason",
699 0 /* Loading failed. */, 1);
696 ASSERT_NO_FATAL_FAILURE( 700 ASSERT_NO_FATAL_FAILURE(
697 CompleteCheckin(kDeviceAndroidId2, kDeviceSecurityToken2, std::string(), 701 CompleteCheckin(kDeviceAndroidId2, kDeviceSecurityToken2, std::string(),
698 std::map<std::string, std::string>())); 702 std::map<std::string, std::string>()));
699 703
700 EXPECT_EQ(LOADING_COMPLETED, last_event()); 704 EXPECT_EQ(LOADING_COMPLETED, last_event());
701 EXPECT_EQ(kDeviceAndroidId2, mcs_client()->last_android_id()); 705 EXPECT_EQ(kDeviceAndroidId2, mcs_client()->last_android_id());
702 EXPECT_EQ(kDeviceSecurityToken2, mcs_client()->last_security_token()); 706 EXPECT_EQ(kDeviceSecurityToken2, mcs_client()->last_security_token());
703 } 707 }
704 708
705 TEST_F(GCMClientImplTest, LoadingWithEmptyDirectory) { 709 TEST_F(GCMClientImplTest, LoadingWithEmptyDirectory) {
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 EXPECT_TRUE(device_checkin_info().accounts_set); 1238 EXPECT_TRUE(device_checkin_info().accounts_set);
1235 EXPECT_EQ(MakeEmailToTokenMap(account_tokens), 1239 EXPECT_EQ(MakeEmailToTokenMap(account_tokens),
1236 device_checkin_info().account_tokens); 1240 device_checkin_info().account_tokens);
1237 } 1241 }
1238 1242
1239 TEST_F(GCMClientImplCheckinTest, ResetStoreWhenCheckinRejected) { 1243 TEST_F(GCMClientImplCheckinTest, ResetStoreWhenCheckinRejected) {
1240 base::HistogramTester histogram_tester; 1244 base::HistogramTester histogram_tester;
1241 std::map<std::string, std::string> settings; 1245 std::map<std::string, std::string> settings;
1242 ASSERT_NO_FATAL_FAILURE(FailCheckin(net::HTTP_UNAUTHORIZED)); 1246 ASSERT_NO_FATAL_FAILURE(FailCheckin(net::HTTP_UNAUTHORIZED));
1243 PumpLoopUntilIdle(); 1247 PumpLoopUntilIdle();
1248 histogram_tester.ExpectUniqueSample("GCM.ResetStoreReason",
1249 1 /* Checkin rejected. */, 1);
1244 1250
1245 // Store should have been destroyed. Restart client and verify the initial 1251 // Store should have been destroyed. Restart client and verify the initial
1246 // checkin response is persisted. 1252 // checkin response is persisted.
1247 BuildGCMClient(base::TimeDelta()); 1253 BuildGCMClient(base::TimeDelta());
1248 InitializeGCMClient(); 1254 InitializeGCMClient();
1249 StartGCMClient(); 1255 StartGCMClient();
1250 ASSERT_NO_FATAL_FAILURE( 1256 ASSERT_NO_FATAL_FAILURE(
1251 CompleteCheckin(kDeviceAndroidId2, kDeviceSecurityToken2, 1257 CompleteCheckin(kDeviceAndroidId2, kDeviceSecurityToken2,
1252 GServicesSettings::CalculateDigest(settings), settings)); 1258 GServicesSettings::CalculateDigest(settings), settings));
1253 1259
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 ReceiveMessageFromMCS(message); 1921 ReceiveMessageFromMCS(message);
1916 1922
1917 EXPECT_EQ(MESSAGE_RECEIVED, last_event()); 1923 EXPECT_EQ(MESSAGE_RECEIVED, last_event());
1918 EXPECT_EQ(kExtensionAppId, last_app_id()); 1924 EXPECT_EQ(kExtensionAppId, last_app_id());
1919 EXPECT_EQ(expected_data.size(), last_message().data.size()); 1925 EXPECT_EQ(expected_data.size(), last_message().data.size());
1920 EXPECT_EQ(expected_data, last_message().data); 1926 EXPECT_EQ(expected_data, last_message().data);
1921 EXPECT_EQ(kSender, last_message().sender_id); 1927 EXPECT_EQ(kSender, last_message().sender_id);
1922 } 1928 }
1923 1929
1924 } // namespace gcm 1930 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698