18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file. 48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/test/launcher/test_result.h" 68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "base/logging.h" 88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace base { 108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)TestResult::TestResult() : status(TEST_UNKNOWN) { 128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)TestResult::~TestResult() { 158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)std::string TestResult::StatusAsString() const { 188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) switch (status) { 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) case TEST_UNKNOWN: 208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return "UNKNOWN"; 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) case TEST_SUCCESS: 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return "SUCCESS"; 238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) case TEST_FAILURE: 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return "FAILURE"; 25f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) case TEST_FAILURE_ON_EXIT: 26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) return "FAILURE_ON_EXIT"; 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) case TEST_CRASH: 288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return "CRASH"; 298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) case TEST_TIMEOUT: 308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return "TIMEOUT"; 318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) case TEST_SKIPPED: 328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return "SKIPPED"; 338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Rely on compiler warnings to ensure all possible values are handled. 348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) } 358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) NOTREACHED(); 378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return std::string(); 388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)std::string TestResult::GetTestName() const { 411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) size_t dot_pos = full_name.find('.'); 421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) CHECK_NE(dot_pos, std::string::npos); 431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return full_name.substr(dot_pos + 1); 441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)std::string TestResult::GetTestCaseName() const { 471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) size_t dot_pos = full_name.find('.'); 481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) CHECK_NE(dot_pos, std::string::npos); 491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return full_name.substr(0, dot_pos); 501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} // namespace base 53