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
);
38 TEST(LibValuesUnittest
, GetEventFromName
) {
39 rlz_lib::SetExpectedAssertion("GetEventFromName: event is NULL");
40 EXPECT_FALSE(rlz_lib::GetEventFromName("", NULL
));
41 rlz_lib::SetExpectedAssertion("");
44 EXPECT_FALSE(rlz_lib::GetEventFromName(NULL
, &event
));
45 EXPECT_EQ(rlz_lib::INVALID_EVENT
, event
);
47 EXPECT_TRUE(rlz_lib::GetEventFromName("", &event
));
48 EXPECT_EQ(rlz_lib::INVALID_EVENT
, event
);
50 EXPECT_FALSE(rlz_lib::GetEventFromName("i1", &event
));
51 EXPECT_EQ(rlz_lib::INVALID_EVENT
, event
);
53 EXPECT_TRUE(rlz_lib::GetEventFromName("I", &event
));
54 EXPECT_EQ(rlz_lib::INSTALL
, event
);
56 EXPECT_TRUE(rlz_lib::GetEventFromName("F", &event
));
57 EXPECT_EQ(rlz_lib::FIRST_SEARCH
, event
);
59 EXPECT_FALSE(rlz_lib::GetEventFromName("F ", &event
));
60 EXPECT_EQ(rlz_lib::INVALID_EVENT
, event
);