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
3 // found in the LICENSE file.
5 #include "rlz/lib/lib_values.h"
7 #include "base/logging.h"
8 #include "rlz/lib/assert.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 TEST(LibValuesUnittest
, GetAccessPointFromName
) {
13 rlz_lib::SetExpectedAssertion("GetAccessPointFromName: point is NULL");
14 EXPECT_FALSE(rlz_lib::GetAccessPointFromName("", NULL
));
15 rlz_lib::SetExpectedAssertion("");
17 rlz_lib::AccessPoint point
;
18 EXPECT_FALSE(rlz_lib::GetAccessPointFromName(NULL
, &point
));
19 EXPECT_EQ(rlz_lib::NO_ACCESS_POINT
, point
);
21 EXPECT_TRUE(rlz_lib::GetAccessPointFromName("", &point
));
22 EXPECT_EQ(rlz_lib::NO_ACCESS_POINT
, point
);
24 EXPECT_FALSE(rlz_lib::GetAccessPointFromName("i1", &point
));
25 EXPECT_EQ(rlz_lib::NO_ACCESS_POINT
, point
);
27 EXPECT_TRUE(rlz_lib::GetAccessPointFromName("I7", &point
));
28 EXPECT_EQ(rlz_lib::IE_DEFAULT_SEARCH
, point
);
30 EXPECT_TRUE(rlz_lib::GetAccessPointFromName("T4", &point
));
31 EXPECT_EQ(rlz_lib::IETB_SEARCH_BOX
, point
);
33 EXPECT_FALSE(rlz_lib::GetAccessPointFromName("T4 ", &point
));
34 EXPECT_EQ(rlz_lib::NO_ACCESS_POINT
, point
);
36 for (int ap
= rlz_lib::NO_ACCESS_POINT
+ 1;
37 ap
< rlz_lib::LAST_ACCESS_POINT
; ++ap
) {
38 rlz_lib::AccessPoint point
= static_cast<rlz_lib::AccessPoint
>(ap
);
39 EXPECT_TRUE(GetAccessPointName(point
) != NULL
);
43 TEST(LibValuesUnittest
, GetEventFromName
) {
44 rlz_lib::SetExpectedAssertion("GetEventFromName: event is NULL");
45 EXPECT_FALSE(rlz_lib::GetEventFromName("", NULL
));
46 rlz_lib::SetExpectedAssertion("");
49 EXPECT_FALSE(rlz_lib::GetEventFromName(NULL
, &event
));
50 EXPECT_EQ(rlz_lib::INVALID_EVENT
, event
);
52 EXPECT_TRUE(rlz_lib::GetEventFromName("", &event
));
53 EXPECT_EQ(rlz_lib::INVALID_EVENT
, event
);
55 EXPECT_FALSE(rlz_lib::GetEventFromName("i1", &event
));
56 EXPECT_EQ(rlz_lib::INVALID_EVENT
, event
);
58 EXPECT_TRUE(rlz_lib::GetEventFromName("I", &event
));
59 EXPECT_EQ(rlz_lib::INSTALL
, event
);
61 EXPECT_TRUE(rlz_lib::GetEventFromName("F", &event
));
62 EXPECT_EQ(rlz_lib::FIRST_SEARCH
, event
);
64 EXPECT_FALSE(rlz_lib::GetEventFromName("F ", &event
));
65 EXPECT_EQ(rlz_lib::INVALID_EVENT
, event
);