diff --git a/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php b/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php
new file mode 100644
index 0000000..d9d8d69
--- /dev/null
+++ b/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\system\Tests\Entity\FieldWidgetConstraintValidatorTest.
+ */
+
+namespace Drupal\system\Tests\Entity;
+
+use Drupal\Core\Form\FormState;
+use Drupal\Core\TypedData\DataDefinition;
+use Drupal\entity\Entity\EntityFormDisplay;
+use Drupal\simpletest\DrupalUnitTestBase;
+use Drupal\system\Tests\TypedData;
+
+/**
+ * Tests validation constraints for FieldWidgetConstraintValidatorTest.
+ *
+ * @group Entity
+ */
+class FieldWidgetConstraintValidatorTest extends DrupalUnitTestBase {
+
+  public static $modules = array('entity', 'entity_test', 'field', 'user');
+
+  /**
+   * Tests widget constraint validation.
+   */
+  public function testValidation() {
+    $entity_type = 'entity_test_constraint_violation';
+    $entity = entity_create($entity_type, array('id' => 1, 'revision_id' => 1));
+    $display = entity_get_form_display($entity_type, $entity_type, 'default');
+    $form = array();
+    $form_state = new FormState();
+    $display->buildForm($entity, $form, $form_state);
+
+    // Pretend the form has been built.
+    $form_state['build_info']['callback_object'] = \Drupal::entityManager()->getFormObject($entity_type, 'default');
+    \Drupal::formBuilder()->prepareForm('field_test_entity_form', $form, $form_state);
+    drupal_process_form('field_test_entity_form', $form, $form_state);
+
+    // Validate the field constraint.
+    $display->validateFormValues($entity, $form, $form_state);
+
+    $errors = $form_state->getErrors();
+    $this->assertEqual($errors['name'], 'Widget constraint has failed.', 'Constraint violation is generated correctly');
+  }
+
+}
diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php
new file mode 100644
index 0000000..79549fc
--- /dev/null
+++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\entity_test\Entity\EntityTest.
+ */
+
+namespace Drupal\entity_test\Entity;
+
+use Drupal\Core\Entity\ContentEntityBase;
+use Drupal\Core\Entity\EntityTypeInterface;
+use Drupal\Core\Field\BaseFieldDefinition;
+use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\user\EntityOwnerInterface;
+use Drupal\user\UserInterface;
+
+/**
+ * Defines the test entity class.
+ *
+ * @ContentEntityType(
+ *   id = "entity_test_constraint_violation",
+ *   label = @Translation("Test entity constraint violation"),
+ *   controllers = {
+ *     "form" = {
+ *       "default" = "Drupal\entity_test\EntityTestForm"
+ *     }
+ *   },
+ *   base_table = "entity_test",
+ *   fieldable = TRUE,
+ *   persistent_cache = FALSE,
+ *   entity_keys = {
+ *     "id" = "id",
+ *     "uuid" = "uuid",
+ *     "bundle" = "type",
+ *     "label" = "name"
+ *   }
+ * )
+ */
+class EntityTestConstraintViolation extends EntityTest {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
+    $fields = parent::baseFieldDefinitions($entity_type);
+
+    $fields['name']->setDisplayOptions('form', array(
+      'type' => 'string',
+      'weight' => 0,
+    ));
+    $fields['name']->addConstraint('FieldWidgetConstraint', array());
+
+
+
+    return $fields;
+  }
+
+}
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraint.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraint.php
new file mode 100644
index 0000000..2547f60
--- /dev/null
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraint.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * @file
+ * Contains \Drupal\entity_test\Plugin\Validation\Constraint\FieldWidgetConstraint.php
+ */
+
+namespace Drupal\entity_test\Plugin\Validation\Constraint;
+
+use Symfony\Component\Validator\Constraint;
+
+/**
+ * Supports validating widget constraints.
+ *
+ * @Plugin(
+ * id = "FieldWidgetConstraint",
+ * label = @Translation("Field widget constraint.")
+ * )
+ */
+class FieldWidgetConstraint extends Constraint {
+
+  public $message = 'Widget constraint has failed.';
+
+}
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraintValidator.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraintValidator.php
new file mode 100644
index 0000000..84da84b
--- /dev/null
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraintValidator.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * @file
+ * Contains \Drupal\entity_test\Plugin\Validation\Constraint\FieldWidgetConstraintValidator.php
+ */
+
+namespace Drupal\entity_test\Plugin\Validation\Constraint;
+
+use Symfony\Component\Validator\Constraint;
+use Symfony\Component\Validator\ConstraintValidator;
+
+/**
+ * Validates the FieldWidgetConstraint constraint.
+ */
+class FieldWidgetConstraintValidator extends ConstraintValidator {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validate($field_item, Constraint $constraint) {
+    $this->context->addViolation($constraint->message);
+  }
+
+}
