OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/routing_id_issuer.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 |
| 9 namespace content { |
| 10 namespace { |
| 11 |
| 12 const int kMangler = 5; |
| 13 |
| 14 class RoutingIDIssuerTest : public testing::Test {}; |
| 15 |
| 16 TEST_F(RoutingIDIssuerTest, IssueNext) { |
| 17 scoped_ptr<RoutingIDIssuer> target = |
| 18 RoutingIDIssuer::CreateWithMangler(kMangler); |
| 19 int id0 = target->IssueNext(); |
| 20 int id1 = target->IssueNext(); |
| 21 EXPECT_EQ(id0 + 1, id1); |
| 22 } |
| 23 |
| 24 TEST_F(RoutingIDIssuerTest, IsProbablyValid) { |
| 25 scoped_ptr<RoutingIDIssuer> proper = |
| 26 RoutingIDIssuer::CreateWithMangler(kMangler); |
| 27 scoped_ptr<RoutingIDIssuer> foreign = |
| 28 RoutingIDIssuer::CreateWithMangler(kMangler + 1); |
| 29 |
| 30 EXPECT_FALSE(proper->IsProbablyValid(kMangler)); |
| 31 |
| 32 int proper_id = proper->IssueNext(); |
| 33 int foreign_id = foreign->IssueNext(); |
| 34 EXPECT_TRUE(proper->IsProbablyValid(proper_id)); |
| 35 EXPECT_TRUE(foreign->IsProbablyValid(foreign_id)); |
| 36 EXPECT_FALSE(proper->IsProbablyValid(foreign_id)); |
| 37 EXPECT_FALSE(foreign->IsProbablyValid(proper_id)); |
| 38 } |
| 39 |
| 40 } // namespace |
| 41 } // namespace contnet |
OLD | NEW |