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

Side by Side Diff: components/feedback/feedback_common_unittest.cc

Issue 1530403003: Add anonymizer tool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT Created 4 years, 11 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
« no previous file with comments | « components/feedback/anonymizer_tool_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/feedback/feedback_common.h" 5 #include "components/feedback/feedback_common.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "components/feedback/proto/common.pb.h" 8 #include "components/feedback/proto/common.pb.h"
9 #include "components/feedback/proto/dom.pb.h" 9 #include "components/feedback/proto/dom.pb.h"
10 #include "components/feedback/proto/extension.pb.h" 10 #include "components/feedback/proto/extension.pb.h"
11 #include "components/feedback/proto/math.pb.h" 11 #include "components/feedback/proto/math.pb.h"
12 #include "content/public/test/test_browser_thread.h" 12 #include "content/public/test/test_browser_thread.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace { 15 namespace {
16 const char kOne[] = "one"; 16 const char kOne[] = "one";
17 const char kTwo[] = "two"; 17 const char kTwo[] = "two";
18 const char kThree[] = "three"; 18 const char kThree[] = "three";
19 const char kFour[] = "four"; 19 const char kFour[] = "four";
20 #define TEN_LINES "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n" 20 #define TEN_LINES "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n"
21 const char kLongLog[] = TEN_LINES TEN_LINES TEN_LINES TEN_LINES TEN_LINES; 21 const char kLongLog[] = TEN_LINES TEN_LINES TEN_LINES TEN_LINES TEN_LINES;
22 const char kLogsAttachmentName[] = "system_logs.zip"; 22 const char kLogsAttachmentName[] = "system_logs.zip";
23 } // namespace 23 } // namespace
24 24
25 class FeedbackCommonTest : public testing::Test { 25 class FeedbackCommonTest : public testing::Test {
26 protected: 26 protected:
27 FeedbackCommonTest() { 27 FeedbackCommonTest() {
28 feedback = scoped_refptr<FeedbackCommon>(new FeedbackCommon()); 28 feedback_ = scoped_refptr<FeedbackCommon>(new FeedbackCommon());
29 } 29 }
30 30
31 ~FeedbackCommonTest() override {} 31 ~FeedbackCommonTest() override {}
32 32
33 scoped_refptr<FeedbackCommon> feedback; 33 scoped_refptr<FeedbackCommon> feedback_;
34 userfeedback::ExtensionSubmit report; 34 userfeedback::ExtensionSubmit report_;
35 }; 35 };
36 36
37 TEST_F(FeedbackCommonTest, TestBasicData) { 37 TEST_F(FeedbackCommonTest, TestBasicData) {
38 // Test that basic data can be set and propagates to the request. 38 // Test that basic data can be set and propagates to the request.
39 feedback->set_category_tag(kOne); 39 feedback_->set_category_tag(kOne);
40 feedback->set_description(kTwo); 40 feedback_->set_description(kTwo);
41 feedback->set_page_url(kThree); 41 feedback_->set_page_url(kThree);
42 feedback->set_user_email(kFour); 42 feedback_->set_user_email(kFour);
43 feedback->PrepareReport(&report); 43 feedback_->PrepareReport(&report_);
44 44
45 EXPECT_EQ(kOne, report.bucket()); 45 EXPECT_EQ(kOne, report_.bucket());
46 EXPECT_EQ(kTwo, report.common_data().description()); 46 EXPECT_EQ(kTwo, report_.common_data().description());
47 EXPECT_EQ(kThree, report.web_data().url()); 47 EXPECT_EQ(kThree, report_.web_data().url());
48 EXPECT_EQ(kFour, report.common_data().user_email()); 48 EXPECT_EQ(kFour, report_.common_data().user_email());
49 } 49 }
50 50
51 TEST_F(FeedbackCommonTest, TestAddLogs) { 51 TEST_F(FeedbackCommonTest, TestAddLogs) {
52 feedback->AddLog(kOne, kTwo); 52 feedback_->AddLog(kOne, kTwo);
53 feedback->AddLog(kThree, kFour); 53 feedback_->AddLog(kThree, kFour);
54 54
55 EXPECT_EQ(2U, feedback->sys_info()->size()); 55 EXPECT_EQ(2U, feedback_->sys_info()->size());
56 } 56 }
57 57
58 TEST_F(FeedbackCommonTest, TestCompressionThreshold) { 58 TEST_F(FeedbackCommonTest, TestCompressionThreshold) {
59 // Add a large and small log, verify that only the small log gets 59 // Add a large and small log, verify that only the small log gets
60 // included in the report. 60 // included in the report.
61 feedback->AddLog(kOne, kTwo); 61 feedback_->AddLog(kOne, kTwo);
62 feedback->AddLog(kThree, kLongLog); 62 feedback_->AddLog(kThree, kLongLog);
63 feedback->PrepareReport(&report); 63 feedback_->PrepareReport(&report_);
64 64
65 EXPECT_EQ(1, report.web_data().product_specific_data_size()); 65 EXPECT_EQ(1, report_.web_data().product_specific_data_size());
66 EXPECT_EQ(kOne, report.web_data().product_specific_data(0).key()); 66 EXPECT_EQ(kOne, report_.web_data().product_specific_data(0).key());
67 } 67 }
68 68
69 TEST_F(FeedbackCommonTest, TestCompression) { 69 TEST_F(FeedbackCommonTest, TestCompression) {
70 // Add a large and small log, verify that an attachment has been 70 // Add a large and small log, verify that an attachment has been
71 // added with the right name. 71 // added with the right name.
72 feedback->AddLog(kOne, kTwo); 72 feedback_->AddLog(kOne, kTwo);
73 feedback->AddLog(kThree, kLongLog); 73 feedback_->AddLog(kThree, kLongLog);
74 feedback->CompressLogs(); 74 feedback_->CompressLogs();
75 feedback->PrepareReport(&report); 75 feedback_->PrepareReport(&report_);
76 76
77 EXPECT_EQ(1, report.product_specific_binary_data_size()); 77 EXPECT_EQ(1, report_.product_specific_binary_data_size());
78 EXPECT_EQ(kLogsAttachmentName, report.product_specific_binary_data(0).name()); 78 EXPECT_EQ(kLogsAttachmentName,
79 report_.product_specific_binary_data(0).name());
79 } 80 }
OLDNEW
« no previous file with comments | « components/feedback/anonymizer_tool_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698