summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/ibus/ibus_property_unittest.cc
diff options
context:
space:
mode:
authornona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-21 07:14:50 +0000
committernona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-21 07:14:50 +0000
commit3409f56de394dabf8a2d14bd036478a8d93638f1 (patch)
tree1048ae33d95ba9f47389486fd20f0c4a374a7b28 /chromeos/dbus/ibus/ibus_property_unittest.cc
parent53fda783a1274fb0ee9b46cc90b0874ca5e4479f (diff)
downloadchromium_src-3409f56de394dabf8a2d14bd036478a8d93638f1.zip
chromium_src-3409f56de394dabf8a2d14bd036478a8d93638f1.tar.gz
chromium_src-3409f56de394dabf8a2d14bd036478a8d93638f1.tar.bz2
Revert 143355 - Implement IBusProperty
IBusProperty and IBusPropertyList are one of representations an obeject used in communication with ibus-daemon. According to this CL, ibus_property.cc will be comipled and tested but not in used production binary at thi moment. BUG=chromium-os:26334 TEST=chromeos_unittests, unit_tests, dbus_unittests Review URL: https://chromiumcodereview.appspot.com/10383253 TBR=nona@chromium.org Review URL: https://chromiumcodereview.appspot.com/10619003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143358 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/ibus/ibus_property_unittest.cc')
-rw-r--r--chromeos/dbus/ibus/ibus_property_unittest.cc122
1 files changed, 0 insertions, 122 deletions
diff --git a/chromeos/dbus/ibus/ibus_property_unittest.cc b/chromeos/dbus/ibus/ibus_property_unittest.cc
deleted file mode 100644
index 9eca37f..0000000
--- a/chromeos/dbus/ibus/ibus_property_unittest.cc
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-#include "chromeos/dbus/ibus/ibus_property.h"
-
-#include <string>
-
-#include "base/compiler_specific.h"
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/stringprintf.h"
-#include "chromeos/dbus/ibus/ibus_object.h"
-#include "dbus/message.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chromeos {
-namespace ibus {
-
-namespace {
-
-const char kSampleKey[] = "Key";
-const IBusProperty::IBusPropertyType kSampleType =
- IBusProperty::IBUS_PROPERTY_TYPE_RADIO;
-const char kSampleLabel[] = "Label";
-const char kSampleTooltip[] = "Tooltip";
-const bool kSampleVisible = true;
-const bool kSampleChecked = false;
-
-// Sets testing data to |property| with |prefix|.
-// This function clears IBusProperty::sub_properties_ and does not add any
-// entries into it. The testing data can be checked with CheckProperty function
-// with same |prefix|.
-void SetProperty(const std::string& prefix, IBusProperty* property) {
- property->set_key(prefix + kSampleKey);
- property->set_type(kSampleType);
- property->set_label(prefix + kSampleLabel);
- property->set_tooltip(prefix + kSampleTooltip);
- property->set_visible(kSampleVisible);
- property->set_checked(kSampleChecked);
- property->mutable_sub_properties()->reset();
-}
-
-// Checks testing data in |property| with |prefix|.
-// This function does not check IBusProperty::sub_properties_.
-bool CheckProperty(const std::string& prefix, const IBusProperty& property) {
- if ((prefix + kSampleKey) != property.key()) {
- LOG(ERROR) << "Does not match IBusProperty::key value: " << std::endl
- << "Expected: " << (prefix + kSampleKey) << std::endl
- << "Actual: " << property.key();
- return false;
- }
- if (kSampleType != property.type()) {
- LOG(ERROR) << "Does not match IBusProperty::type value: " << std::endl
- << "Expected: " << kSampleType << std::endl
- << "Actual: " << property.type();
- return false;
- }
- if ((prefix + kSampleLabel) != property.label()) {
- LOG(ERROR) << "Does not match IBusProperty::label value: " << std::endl
- << "Expected: " << (prefix + kSampleLabel) << std::endl
- << "Actual: " << property.label();
- return false;
- }
- if ((prefix + kSampleTooltip) != property.tooltip()) {
- LOG(ERROR) << "Does not match IBusProperty::tooltip value: " << std::endl
- << "Expected: " << (prefix + kSampleTooltip) << std::endl
- << "Actual: " << property.tooltip();
- return false;
- }
- if (kSampleVisible != property.visible()) {
- LOG(ERROR) << "Does not match IBusProperty::visible value: " << std::endl
- << "Expected: " << kSampleVisible << std::endl
- << "Actual: " << property.visible();
- return false;
- }
- if (kSampleChecked != property.checked()) {
- LOG(ERROR) << "Does not match IBusProperty::state value: " << std::endl
- << "Expected: " << kSampleChecked << std::endl
- << "Actual: " << property.checked();
- return false;
- }
- return true;
-}
-
-} // namespace
-
-TEST(IBusPropertyListTest, WriteReadIBusPropertyTest) {
- const size_t kSubPropertyCount = 16;
-
- // Create a IBusProperty.
- IBusProperty property;
- SetProperty("Root_", &property);
- for (size_t i = 0; i < kSubPropertyCount; ++i) {
- const std::string prefix = base::StringPrintf("Sub%lu_", i);
- IBusProperty* sub_property = new IBusProperty;
- SetProperty(prefix, sub_property);
- property.mutable_sub_properties()->push_back(sub_property);
- }
-
- // Write a IBusProperty.
- scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
- dbus::MessageWriter writer(response.get());
- AppendIBusProperty(property, &writer);
-
- // Read a IBusProperty.
- IBusProperty target_property;
- dbus::MessageReader reader(response.get());
- PopIBusProperty(&reader, &target_property);
-
- // Check a result.
- EXPECT_TRUE(CheckProperty("Root_", target_property));
- const IBusPropertyList& sub_properties = target_property.sub_properties();
- ASSERT_EQ(kSubPropertyCount, sub_properties.size());
- for (size_t i = 0; i < kSubPropertyCount; ++i) {
- const std::string prefix = base::StringPrintf("Sub%lu_", i);
- EXPECT_TRUE(CheckProperty(prefix, *(sub_properties[i])));
- }
-}
-
-} // namespace ibus
-} // namespace chromeos