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

Side by Side Diff: components/browser_watcher/postmortem_report_collector_unittest.cc

Issue 2691033002: Collect field trial information from the stability file (Closed)
Patch Set: Address rkaplow's comments Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/browser_watcher/postmortem_report_collector.h" 5 #include "components/browser_watcher/postmortem_report_collector.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 ContainsKeyValue(collected_data, kStabilityReporterChannel, kChannelName); 643 ContainsKeyValue(collected_data, kStabilityReporterChannel, kChannelName);
644 #if defined(ARCH_CPU_X86) 644 #if defined(ARCH_CPU_X86)
645 ContainsKeyValue(collected_data, kStabilityReporterPlatform, "Win32"); 645 ContainsKeyValue(collected_data, kStabilityReporterPlatform, "Win32");
646 #elif defined(ARCH_CPU_X86_64) 646 #elif defined(ARCH_CPU_X86_64)
647 ContainsKeyValue(collected_data, kStabilityReporterPlatform, "Win64"); 647 ContainsKeyValue(collected_data, kStabilityReporterPlatform, "Win64");
648 #endif 648 #endif
649 ContainsKeyValue(collected_data, kStabilityReporterVersion, kVersionNumber); 649 ContainsKeyValue(collected_data, kStabilityReporterVersion, kVersionNumber);
650 } 650 }
651 651
652 TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest, 652 TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest,
653 FieldTrialCollection) {
654 // Record some data.
655 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL,
656 "", 3);
657 ActivityUserData& global_data = GlobalActivityTracker::Get()->global_data();
658 global_data.SetString("string", "bar");
659 global_data.SetString("FieldTrial.string", "bar");
660 global_data.SetString("FieldTrial.foo", "bar");
661
662 // Collect the stability report.
663 PostmortemReportCollector collector(kProductName, kVersionNumber,
664 kChannelName);
665 std::unique_ptr<StabilityReport> report;
666 ASSERT_EQ(PostmortemReportCollector::SUCCESS,
667 collector.Collect(debug_file_path(), &report));
668 ASSERT_NE(nullptr, report);
669
670 // Validate the report's experiment and global data.
671 ASSERT_EQ(2, report->field_trials_size());
672 EXPECT_NE(0U, report->field_trials(0).name_id());
673 EXPECT_NE(0U, report->field_trials(0).group_id());
674 EXPECT_NE(0U, report->field_trials(1).name_id());
675 EXPECT_EQ(report->field_trials(0).group_id(),
676 report->field_trials(1).group_id());
677
678 // Expect 5 key/value pairs (including product details).
679 const auto& collected_data = report->global_data();
680 EXPECT_EQ(5U, collected_data.size());
681 EXPECT_TRUE(base::ContainsKey(collected_data, "string"));
682 }
683
684 TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest,
653 ModuleCollection) { 685 ModuleCollection) {
654 // Record some module information. 686 // Record some module information.
655 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL, 687 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL,
656 "", 3); 688 "", 3);
657 689
658 base::debug::GlobalActivityTracker::ModuleInfo module_info = {}; 690 base::debug::GlobalActivityTracker::ModuleInfo module_info = {};
659 module_info.is_loaded = true; 691 module_info.is_loaded = true;
660 module_info.address = 0x123456; 692 module_info.address = 0x123456;
661 module_info.load_time = 1111LL; 693 module_info.load_time = 1111LL;
662 module_info.size = 0x2d000; 694 module_info.size = 0x2d000;
(...skipping 28 matching lines...) Expand all
691 EXPECT_EQ("CAFECAFE2d000", collected_module.code_identifier()); 723 EXPECT_EQ("CAFECAFE2d000", collected_module.code_identifier());
692 EXPECT_EQ(module_info.debug_file, collected_module.debug_file()); 724 EXPECT_EQ(module_info.debug_file, collected_module.debug_file());
693 EXPECT_EQ("1122334455667788ABCD0123456789AB1", 725 EXPECT_EQ("1122334455667788ABCD0123456789AB1",
694 collected_module.debug_identifier()); 726 collected_module.debug_identifier());
695 EXPECT_EQ("", collected_module.version()); 727 EXPECT_EQ("", collected_module.version());
696 EXPECT_EQ(0LL, collected_module.shrink_down_delta()); 728 EXPECT_EQ(0LL, collected_module.shrink_down_delta());
697 EXPECT_EQ(!module_info.is_loaded, collected_module.is_unloaded()); 729 EXPECT_EQ(!module_info.is_loaded, collected_module.is_unloaded());
698 } 730 }
699 731
700 } // namespace browser_watcher 732 } // namespace browser_watcher
OLDNEW
« no previous file with comments | « components/browser_watcher/postmortem_report_collector.cc ('k') | components/browser_watcher/stability_report.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698