Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: content/browser/renderer_host/routing_id_issuer_unittest.cc

Issue 643733002: Add RoutingIDIssuer to ensure the correctness of ID to be routed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/routing_id_issuer.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « content/browser/renderer_host/routing_id_issuer.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698