| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | |
| 6 #include <ctype.h> | 5 #include <ctype.h> |
| 7 #include <string> | 6 #include <string> |
| 8 | 7 |
| 9 #include "chrome/browser/metrics/metrics_service.h" | 8 #include "chrome/browser/metrics/metrics_service.h" |
| 9 #include "chrome/common/chrome_process_type.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 // Ensure the ClientId is formatted as expected. | 12 // Ensure the ClientId is formatted as expected. |
| 13 TEST(MetricsServiceTest, ClientIdCorrectlyFormatted) { | 13 TEST(MetricsServiceTest, ClientIdCorrectlyFormatted) { |
| 14 std::string clientid = MetricsService::GenerateClientID(); | 14 std::string clientid = MetricsService::GenerateClientID(); |
| 15 EXPECT_EQ(36U, clientid.length()); | 15 EXPECT_EQ(36U, clientid.length()); |
| 16 | 16 |
| 17 for (size_t i = 0; i < clientid.length(); ++i) { | 17 for (size_t i = 0; i < clientid.length(); ++i) { |
| 18 char current = clientid[i]; | 18 char current = clientid[i]; |
| 19 if (i == 8 || i == 13 || i == 18 || i == 23) | 19 if (i == 8 || i == 13 || i == 18 || i == 23) |
| 20 EXPECT_EQ('-', current); | 20 EXPECT_EQ('-', current); |
| 21 else | 21 else |
| 22 EXPECT_TRUE(isxdigit(current)); | 22 EXPECT_TRUE(isxdigit(current)); |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 TEST(MetricsServiceTest, IsPluginProcess) { | 26 TEST(MetricsServiceTest, IsPluginProcess) { |
| 27 EXPECT_TRUE( | 27 EXPECT_TRUE( |
| 28 MetricsService::IsPluginProcess(content::PROCESS_TYPE_PLUGIN)); | 28 MetricsService::IsPluginProcess(content::PROCESS_TYPE_PLUGIN)); |
| 29 EXPECT_TRUE( | 29 EXPECT_TRUE( |
| 30 MetricsService::IsPluginProcess(content::PROCESS_TYPE_PPAPI_PLUGIN)); | 30 MetricsService::IsPluginProcess(content::PROCESS_TYPE_PPAPI_PLUGIN)); |
| 31 EXPECT_FALSE( | 31 EXPECT_FALSE( |
| 32 MetricsService::IsPluginProcess(content::PROCESS_TYPE_GPU)); | 32 MetricsService::IsPluginProcess(content::PROCESS_TYPE_GPU)); |
| 33 } | 33 } |
| OLD | NEW |