Home | History | Annotate | Download | only in lib
      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.
      4 
      5 #include "rlz/lib/lib_values.h"
      6 
      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"
     11 
     12 TEST(LibValuesUnittest, GetAccessPointFromName) {
     13   rlz_lib::SetExpectedAssertion("GetAccessPointFromName: point is NULL");
     14   EXPECT_FALSE(rlz_lib::GetAccessPointFromName("", NULL));
     15   rlz_lib::SetExpectedAssertion("");
     16 
     17   rlz_lib::AccessPoint point;
     18   EXPECT_FALSE(rlz_lib::GetAccessPointFromName(NULL, &point));
     19   EXPECT_EQ(rlz_lib::NO_ACCESS_POINT, point);
     20 
     21   EXPECT_TRUE(rlz_lib::GetAccessPointFromName("", &point));
     22   EXPECT_EQ(rlz_lib::NO_ACCESS_POINT, point);
     23 
     24   EXPECT_FALSE(rlz_lib::GetAccessPointFromName("i1", &point));
     25   EXPECT_EQ(rlz_lib::NO_ACCESS_POINT, point);
     26 
     27   EXPECT_TRUE(rlz_lib::GetAccessPointFromName("I7", &point));
     28   EXPECT_EQ(rlz_lib::IE_DEFAULT_SEARCH, point);
     29 
     30   EXPECT_TRUE(rlz_lib::GetAccessPointFromName("T4", &point));
     31   EXPECT_EQ(rlz_lib::IETB_SEARCH_BOX, point);
     32 
     33   EXPECT_FALSE(rlz_lib::GetAccessPointFromName("T4 ", &point));
     34   EXPECT_EQ(rlz_lib::NO_ACCESS_POINT, point);
     35 }
     36 
     37 
     38 TEST(LibValuesUnittest, GetEventFromName) {
     39   rlz_lib::SetExpectedAssertion("GetEventFromName: event is NULL");
     40   EXPECT_FALSE(rlz_lib::GetEventFromName("", NULL));
     41   rlz_lib::SetExpectedAssertion("");
     42 
     43   rlz_lib::Event event;
     44   EXPECT_FALSE(rlz_lib::GetEventFromName(NULL, &event));
     45   EXPECT_EQ(rlz_lib::INVALID_EVENT, event);
     46 
     47   EXPECT_TRUE(rlz_lib::GetEventFromName("", &event));
     48   EXPECT_EQ(rlz_lib::INVALID_EVENT, event);
     49 
     50   EXPECT_FALSE(rlz_lib::GetEventFromName("i1", &event));
     51   EXPECT_EQ(rlz_lib::INVALID_EVENT, event);
     52 
     53   EXPECT_TRUE(rlz_lib::GetEventFromName("I", &event));
     54   EXPECT_EQ(rlz_lib::INSTALL, event);
     55 
     56   EXPECT_TRUE(rlz_lib::GetEventFromName("F", &event));
     57   EXPECT_EQ(rlz_lib::FIRST_SEARCH, event);
     58 
     59   EXPECT_FALSE(rlz_lib::GetEventFromName("F ", &event));
     60   EXPECT_EQ(rlz_lib::INVALID_EVENT, event);
     61 }
     62