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

Unified Diff: chrome/app/breakpad_win_unittest.cc

Issue 9432033: Add experiments info to crash dumps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | chrome/app/run_all_unittests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/breakpad_win_unittest.cc
===================================================================
--- chrome/app/breakpad_win_unittest.cc (revision 0)
+++ chrome/app/breakpad_win_unittest.cc (revision 0)
@@ -0,0 +1,99 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/metrics/field_trial.h"
+#include "base/stringprintf.h"
+#include "breakpad/src/client/windows/common/ipc_protocol.h"
+#include "chrome/common/child_process_logging.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// Entry points of breakpad_win.cc not exposed in any header.
Mark Seaborn 2012/03/12 21:35:09 Why not just put these into breakpad_win.h?
MAD 2012/03/13 23:37:37 Yeah, you're right... Will do... Thanks!
+void TestUpdateExperiments();
+google_breakpad::CustomClientInfo* TestGetCustomInfo();
+
+class ChromeAppBreakpadTest : public testing::Test {
+ public:
+ ChromeAppBreakpadTest()
+ : custom_info_(TestGetCustomInfo()),
+ num_experiments_index_(0) {
+ while (num_experiments_index_ < custom_info_->count) {
+ if (!wcsncmp(custom_info_->entries[num_experiments_index_].name,
+ kNumExperiments, kNumExperimentsSize + 1)) {
+ break;
+ }
+ ++num_experiments_index_;
+ }
+ // We need room for the kMaxReportedExperimentChunks experiment chunks.
+ EXPECT_GE(custom_info_->count,
+ num_experiments_index_ + kMaxReportedExperimentChunks);
+ }
+
+ protected:
+ typedef std::vector<base::FieldTrial::NameGroupId> Experiments;
+ void ValidateExperimentChunks(const Experiments& experiments) {
+ TestUpdateExperiments();
+ EXPECT_STREQ(base::StringPrintf(L"%d", experiments.size()).c_str(),
+ custom_info_->entries[num_experiments_index_].value);
+ // We make a copy of the array that we empty as we find the experiments.
+ Experiments experiments_left(experiments);
+ for (int i = 1; i <= kMaxReportedExperimentChunks; ++i) {
+ EXPECT_STREQ(base::StringPrintf(L"experiment-chunk-%i", i).c_str(),
+ custom_info_->entries[num_experiments_index_ + i].name);
+ if (experiments_left.empty()) {
+ // All other slots should be empty.
+ EXPECT_STREQ(L"",
+ custom_info_->entries[num_experiments_index_ + i].value);
+ } else {
+ // We can't guarantee the order, so we must search for them all.
+ Experiments::const_iterator experiment = experiments_left.begin();
+ while (experiment != experiments_left.end()) {
+ std::wstring experiment_str = base::StringPrintf(
+ L"%x-%x", experiment->name, experiment->group);
+ if (wcsstr(custom_info_->entries[num_experiments_index_ + i].value,
+ experiment_str.c_str())) {
+ experiment = experiments_left.erase(experiment);
+ } else {
+ ++experiment;
+ }
+ }
+ }
+ }
+ EXPECT_TRUE(experiments_left.empty());
+ }
+
+ private:
+ static const wchar_t* kNumExperiments;
+ static const size_t kNumExperimentsSize;
+ google_breakpad::CustomClientInfo* custom_info_;
+ size_t num_experiments_index_;
+};
+
+const wchar_t* ChromeAppBreakpadTest::kNumExperiments = L"num-experiments";
+const size_t ChromeAppBreakpadTest::kNumExperimentsSize =
+ wcslen(ChromeAppBreakpadTest::kNumExperiments);
+
+TEST_F(ChromeAppBreakpadTest, ExperimentList) {
+ base::FieldTrialList field_trial_list("ABCDE");
+ base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial("All", "To");
+ base::FieldTrial::NameGroupId name_group_id;
+ trial->GetNameGroupId(&name_group_id);
+ Experiments experiments;
+ experiments.push_back(name_group_id);
+ ValidateExperimentChunks(experiments);
+
+ trial = base::FieldTrialList::CreateFieldTrial("There", "You Are");
+ trial->GetNameGroupId(&name_group_id);
+ experiments.push_back(name_group_id);
+ ValidateExperimentChunks(experiments);
+
+ trial = base::FieldTrialList::CreateFieldTrial("Peter", "Sellers");
+ trial->GetNameGroupId(&name_group_id);
+ experiments.push_back(name_group_id);
+ ValidateExperimentChunks(experiments);
+
+ trial = base::FieldTrialList::CreateFieldTrial("Eat me", "Drink me");
+ trial->GetNameGroupId(&name_group_id);
+ experiments.push_back(name_group_id);
+ ValidateExperimentChunks(experiments);
+}
Property changes on: chrome\app\breakpad_win_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | chrome/app/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698