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

Side by Side Diff: chromeos_login_unittest.cc

Issue 4132006: [cros] Add *Safe methods to the ownership API (Closed) Base URL: http://git.chromium.org/git/cros.git
Patch Set: comment out NOTREACHED Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium OS 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 "chromeos_login.h"
6 #include "chromeos_login_helpers.h"
7
8 #include "gtest/gtest.h"
9
10 namespace chromeos {
11
12 TEST(ChromeOSLoginApiTest, CryptoBlob) {
13 const char expected[] = "hello";
14 GArray* ary = g_array_sized_new(FALSE, FALSE, 1, strlen(expected));
15 g_array_append_vals(ary, expected, strlen(expected));
16 CryptoBlob* blob = ChromeOSLoginHelpers::CreateCryptoBlob(ary);
17
18 for (int i = 0; i < blob->length; ++i)
19 EXPECT_EQ(blob->data[i], expected[i]);
20 EXPECT_EQ(blob->length, strlen(expected));
21
22 g_array_free(ary, TRUE);
23 ChromeOSLoginHelpers::FreeCryptoBlob(blob);
24 }
25
26 TEST(ChromeOSLoginApiTest, Property) {
27 const char name[] = "name";
28 const char val[] = "val";
29 const char expected[] = "hello";
30 GArray* ary = g_array_sized_new(FALSE, FALSE, 1, strlen(expected));
31 g_array_append_vals(ary, expected, strlen(expected));
32 Property* prop = ChromeOSLoginHelpers::CreateProperty(name, val, ary);
33
34 for (int i = 0; i < prop->signature->length; ++i)
35 EXPECT_EQ(prop->signature->data[i], expected[i]);
36 EXPECT_EQ(prop->signature->length, strlen(expected));
37 EXPECT_EQ(name, std::string(prop->name));
38 EXPECT_EQ(val, std::string(prop->value));
39
40 g_array_free(ary, TRUE);
41 ChromeOSLoginHelpers::FreeProperty(prop);
42 }
43
44 TEST(ChromeOSLoginApiTest, UserList) {
45 // NULL-terminated array of NULL-terminated strings to mimic a GLib
46 // "vector" of strings.
47 const char* names[4] = { "who", "what", "where", NULL };
48 UserList* users = ChromeOSLoginHelpers::CreateUserList(names);
49 int count;
50 for (count = 0; names[count] != NULL; count++)
51 EXPECT_EQ(names[count], std::string(users->users[count]));
52 EXPECT_EQ(count, users->num_users);
53 ChromeOSLoginHelpers::FreeUserList(users);
54 }
55
56 } // namespace chromeos
OLDNEW
« chromeos_login_helpers.cc ('K') | « chromeos_login_helpers.cc ('k') | chromeos_network.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698