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

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: Merge 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 ASSERT_TRUE(base::ContainsKey(collected_data, "sref")); 622 ASSERT_TRUE(base::ContainsKey(collected_data, "sref"));
623 EXPECT_EQ(TypedValue::kStringReference, 623 EXPECT_EQ(TypedValue::kStringReference,
624 collected_data.at("sref").value_case()); 624 collected_data.at("sref").value_case());
625 const TypedValue::Reference& sref = 625 const TypedValue::Reference& sref =
626 collected_data.at("sref").string_reference(); 626 collected_data.at("sref").string_reference();
627 EXPECT_EQ(reinterpret_cast<uintptr_t>(string2), sref.address()); 627 EXPECT_EQ(reinterpret_cast<uintptr_t>(string2), sref.address());
628 EXPECT_EQ(strlen(string2), static_cast<uint64_t>(sref.size())); 628 EXPECT_EQ(strlen(string2), static_cast<uint64_t>(sref.size()));
629 } 629 }
630 630
631 TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest, 631 TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest,
632 FieldTrialCollection) {
633 // Record some data.
634 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL,
635 "", 3);
636 ActivityUserData& global_data = GlobalActivityTracker::Get()->global_data();
637 global_data.SetString("string", "bar");
638 global_data.SetString("FieldTrial.string", "bar");
639 global_data.SetString("FieldTrial.foo", "bar");
640
641 // Collect the stability report.
642 PostmortemReportCollector collector(kProductName, kVersionNumber,
643 kChannelName);
644 std::unique_ptr<StabilityReport> report;
645 ASSERT_EQ(PostmortemReportCollector::SUCCESS,
646 collector.Collect(debug_file_path(), &report));
647 ASSERT_NE(nullptr, report);
648
649 // Validate the report's experiment and global data.
650 ASSERT_EQ(2, report->field_trials_size());
651 EXPECT_NE(0U, report->field_trials(0).name_id());
652 EXPECT_NE(0U, report->field_trials(0).group_id());
653 EXPECT_NE(0U, report->field_trials(1).name_id());
654 EXPECT_EQ(report->field_trials(0).group_id(),
655 report->field_trials(1).group_id());
656
657 const auto& collected_data = report->global_data();
658 ASSERT_EQ(1U, collected_data.size());
659 ASSERT_TRUE(base::ContainsKey(collected_data, "string"));
660 }
661
662 TEST_F(PostmortemReportCollectorCollectionFromGlobalTrackerTest,
632 ModuleCollection) { 663 ModuleCollection) {
633 // Record some module information. 664 // Record some module information.
634 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL, 665 GlobalActivityTracker::CreateWithFile(debug_file_path(), kMemorySize, 0ULL,
635 "", 3); 666 "", 3);
636 667
637 base::debug::GlobalActivityTracker::ModuleInfo module_info = {}; 668 base::debug::GlobalActivityTracker::ModuleInfo module_info = {};
638 module_info.is_loaded = true; 669 module_info.is_loaded = true;
639 module_info.address = 0x123456; 670 module_info.address = 0x123456;
640 module_info.load_time = 1111LL; 671 module_info.load_time = 1111LL;
641 module_info.size = 0x2d000; 672 module_info.size = 0x2d000;
(...skipping 28 matching lines...) Expand all
670 EXPECT_EQ("CAFECAFE2d000", collected_module.code_identifier()); 701 EXPECT_EQ("CAFECAFE2d000", collected_module.code_identifier());
671 EXPECT_EQ(module_info.debug_file, collected_module.debug_file()); 702 EXPECT_EQ(module_info.debug_file, collected_module.debug_file());
672 EXPECT_EQ("1122334455667788ABCD0123456789AB1", 703 EXPECT_EQ("1122334455667788ABCD0123456789AB1",
673 collected_module.debug_identifier()); 704 collected_module.debug_identifier());
674 EXPECT_EQ("", collected_module.version()); 705 EXPECT_EQ("", collected_module.version());
675 EXPECT_EQ(0LL, collected_module.shrink_down_delta()); 706 EXPECT_EQ(0LL, collected_module.shrink_down_delta());
676 EXPECT_EQ(!module_info.is_loaded, collected_module.is_unloaded()); 707 EXPECT_EQ(!module_info.is_loaded, collected_module.is_unloaded());
677 } 708 }
678 709
679 } // namespace browser_watcher 710 } // namespace browser_watcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698