| OLD | NEW |
| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 class FeedbackCommonTest : public testing::Test { | 32 class FeedbackCommonTest : public testing::Test { |
| 33 protected: | 33 protected: |
| 34 FeedbackCommonTest() | 34 FeedbackCommonTest() |
| 35 : feedback_(new FeedbackCommon()) { | 35 : feedback_(new FeedbackCommon()) { |
| 36 } | 36 } |
| 37 | 37 |
| 38 ~FeedbackCommonTest() override {} | 38 ~FeedbackCommonTest() override {} |
| 39 | 39 |
| 40 void CompressLogs() { feedback_->CompressLogs(); } |
| 41 |
| 40 bool FeedbackHasProductId() const { return feedback_->HasProductId(); } | 42 bool FeedbackHasProductId() const { return feedback_->HasProductId(); } |
| 41 | 43 |
| 42 scoped_refptr<FeedbackCommon> feedback_; | 44 scoped_refptr<FeedbackCommon> feedback_; |
| 43 userfeedback::ExtensionSubmit report_; | 45 userfeedback::ExtensionSubmit report_; |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 TEST_F(FeedbackCommonTest, TestBasicData) { | 48 TEST_F(FeedbackCommonTest, TestBasicData) { |
| 47 // Test that basic data can be set and propagates to the request. | 49 // Test that basic data can be set and propagates to the request. |
| 48 feedback_->set_category_tag(kOne); | 50 feedback_->set_category_tag(kOne); |
| 49 feedback_->set_description(kTwo); | 51 feedback_->set_description(kTwo); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 87 |
| 86 EXPECT_EQ(1, report_.web_data().product_specific_data_size()); | 88 EXPECT_EQ(1, report_.web_data().product_specific_data_size()); |
| 87 EXPECT_EQ(kOne, report_.web_data().product_specific_data(0).key()); | 89 EXPECT_EQ(kOne, report_.web_data().product_specific_data(0).key()); |
| 88 } | 90 } |
| 89 | 91 |
| 90 TEST_F(FeedbackCommonTest, TestCompression) { | 92 TEST_F(FeedbackCommonTest, TestCompression) { |
| 91 // Add a large and small log, verify that an attachment has been | 93 // Add a large and small log, verify that an attachment has been |
| 92 // added with the right name. | 94 // added with the right name. |
| 93 feedback_->AddLog(kOne, kTwo); | 95 feedback_->AddLog(kOne, kTwo); |
| 94 feedback_->AddLog(kThree, kLongLog); | 96 feedback_->AddLog(kThree, kLongLog); |
| 95 feedback_->CompressLogs(); | 97 CompressLogs(); |
| 96 feedback_->PrepareReport(&report_); | 98 feedback_->PrepareReport(&report_); |
| 97 | 99 |
| 98 EXPECT_EQ(1, report_.product_specific_binary_data_size()); | 100 EXPECT_EQ(1, report_.product_specific_binary_data_size()); |
| 99 EXPECT_EQ(kLogsAttachmentName, | 101 EXPECT_EQ(kLogsAttachmentName, |
| 100 report_.product_specific_binary_data(0).name()); | 102 report_.product_specific_binary_data(0).name()); |
| 101 } | 103 } |
| OLD | NEW |