| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/test/simple_test_tick_clock.h" | 7 #include "base/test/simple_test_tick_clock.h" |
| 8 #include "extensions/browser/api/cast_channel/cast_auth_util.h" | 8 #include "extensions/browser/api/cast_channel/cast_auth_util.h" |
| 9 #include "extensions/browser/api/cast_channel/logger.h" | 9 #include "extensions/browser/api/cast_channel/logger.h" |
| 10 #include "extensions/browser/api/cast_channel/logger_util.h" | 10 #include "extensions/browser/api/cast_channel/logger_util.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 clock_->Advance(base::TimeDelta::FromMicroseconds(1)); | 102 clock_->Advance(base::TimeDelta::FromMicroseconds(1)); |
| 103 | 103 |
| 104 AuthResult auth_result = AuthResult::CreateWithParseError( | 104 AuthResult auth_result = AuthResult::CreateWithParseError( |
| 105 "No response", AuthResult::ERROR_NO_RESPONSE); | 105 "No response", AuthResult::ERROR_NO_RESPONSE); |
| 106 | 106 |
| 107 logger_->LogSocketChallengeReplyEvent(2, auth_result); | 107 logger_->LogSocketChallengeReplyEvent(2, auth_result); |
| 108 clock_->Advance(base::TimeDelta::FromMicroseconds(1)); | 108 clock_->Advance(base::TimeDelta::FromMicroseconds(1)); |
| 109 | 109 |
| 110 auth_result = | 110 auth_result = |
| 111 AuthResult::CreateWithNSSError("Parsing failed", | 111 AuthResult::CreateWithNSSError("Parsing failed", |
| 112 AuthResult::ERROR_NSS_CERT_PARSING_FAILED, | 112 AuthResult::ERROR_CERT_PARSING_FAILED, |
| 113 kTestNssErrorCode); | 113 kTestNssErrorCode); |
| 114 logger_->LogSocketChallengeReplyEvent(2, auth_result); | 114 logger_->LogSocketChallengeReplyEvent(2, auth_result); |
| 115 | 115 |
| 116 LastErrors last_errors = logger_->GetLastErrors(2); | 116 LastErrors last_errors = logger_->GetLastErrors(2); |
| 117 EXPECT_EQ(last_errors.event_type, proto::AUTH_CHALLENGE_REPLY); | 117 EXPECT_EQ(last_errors.event_type, proto::AUTH_CHALLENGE_REPLY); |
| 118 EXPECT_EQ(last_errors.net_return_value, net::OK); | 118 EXPECT_EQ(last_errors.net_return_value, net::OK); |
| 119 EXPECT_EQ(last_errors.challenge_reply_error_type, | 119 EXPECT_EQ(last_errors.challenge_reply_error_type, |
| 120 proto::CHALLENGE_REPLY_ERROR_NSS_CERT_PARSING_FAILED); | 120 proto::CHALLENGE_REPLY_ERROR_CERT_PARSING_FAILED); |
| 121 EXPECT_EQ(last_errors.nss_error_code, kTestNssErrorCode); | 121 EXPECT_EQ(last_errors.nss_error_code, kTestNssErrorCode); |
| 122 | 122 |
| 123 scoped_ptr<Log> log = GetLog(); | 123 scoped_ptr<Log> log = GetLog(); |
| 124 ASSERT_TRUE(log.get() != NULL); | 124 ASSERT_TRUE(log.get() != NULL); |
| 125 | 125 |
| 126 ASSERT_EQ(2, log->aggregated_socket_event_size()); | 126 ASSERT_EQ(2, log->aggregated_socket_event_size()); |
| 127 { | 127 { |
| 128 const AggregatedSocketEvent& aggregated_socket_event = | 128 const AggregatedSocketEvent& aggregated_socket_event = |
| 129 log->aggregated_socket_event(0); | 129 log->aggregated_socket_event(0); |
| 130 EXPECT_EQ(1, aggregated_socket_event.id()); | 130 EXPECT_EQ(1, aggregated_socket_event.id()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 EXPECT_EQ(5, event.timestamp_micros()); | 170 EXPECT_EQ(5, event.timestamp_micros()); |
| 171 EXPECT_EQ(proto::CHALLENGE_REPLY_ERROR_NO_RESPONSE, | 171 EXPECT_EQ(proto::CHALLENGE_REPLY_ERROR_NO_RESPONSE, |
| 172 event.challenge_reply_error_type()); | 172 event.challenge_reply_error_type()); |
| 173 EXPECT_FALSE(event.has_net_return_value()); | 173 EXPECT_FALSE(event.has_net_return_value()); |
| 174 EXPECT_FALSE(event.has_nss_error_code()); | 174 EXPECT_FALSE(event.has_nss_error_code()); |
| 175 } | 175 } |
| 176 { | 176 { |
| 177 const SocketEvent& event = aggregated_socket_event.socket_event(3); | 177 const SocketEvent& event = aggregated_socket_event.socket_event(3); |
| 178 EXPECT_EQ(EventType::AUTH_CHALLENGE_REPLY, event.type()); | 178 EXPECT_EQ(EventType::AUTH_CHALLENGE_REPLY, event.type()); |
| 179 EXPECT_EQ(6, event.timestamp_micros()); | 179 EXPECT_EQ(6, event.timestamp_micros()); |
| 180 EXPECT_EQ(proto::CHALLENGE_REPLY_ERROR_NSS_CERT_PARSING_FAILED, | 180 EXPECT_EQ(proto::CHALLENGE_REPLY_ERROR_CERT_PARSING_FAILED, |
| 181 event.challenge_reply_error_type()); | 181 event.challenge_reply_error_type()); |
| 182 EXPECT_FALSE(event.has_net_return_value()); | 182 EXPECT_FALSE(event.has_net_return_value()); |
| 183 EXPECT_EQ(kTestNssErrorCode, event.nss_error_code()); | 183 EXPECT_EQ(kTestNssErrorCode, event.nss_error_code()); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 TEST_F(CastChannelLoggerTest, LogLastErrorEvents) { | 188 TEST_F(CastChannelLoggerTest, LogLastErrorEvents) { |
| 189 // Net return value is set to an error | 189 // Net return value is set to an error |
| 190 logger_->LogSocketEventWithRv( | 190 logger_->LogSocketEventWithRv( |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 326 |
| 327 log = GetLog(); | 327 log = GetLog(); |
| 328 ASSERT_TRUE(log.get() != NULL); | 328 ASSERT_TRUE(log.get() != NULL); |
| 329 | 329 |
| 330 EXPECT_EQ(0, log->aggregated_socket_event_size()); | 330 EXPECT_EQ(0, log->aggregated_socket_event_size()); |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace cast_channel | 333 } // namespace cast_channel |
| 334 } // namespace core_api | 334 } // namespace core_api |
| 335 } // namespace extensions | 335 } // namespace extensions |
| OLD | NEW |