diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/DialogTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/DialogTest.php
index 9849cb3..dc3b016 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Ajax/DialogTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/DialogTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\Ajax;
 
-use Drupal\ajax_test\AjaxTestForm;
+use Drupal\ajax_test\Form\AjaxTestForm;
 
 /**
  * Tests use of dialogs as wrappers for Ajax responses.
diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.module b/core/modules/system/tests/modules/ajax_test/ajax_test.module
index 802b34e..9804b1d 100644
--- a/core/modules/system/tests/modules/ajax_test/ajax_test.module
+++ b/core/modules/system/tests/modules/ajax_test/ajax_test.module
@@ -87,171 +87,6 @@ function ajax_test_error() {
 }
 
 /**
- * Menu callback: Renders a form elements and links with #ajax['dialog'].
- *
- * @deprecated \Drupal\ajax_test\Controller\AjaxTestController::dialog()
- */
-function ajax_test_dialog() {
-  // Add two wrapper elements for testing non-modal dialogs. Modal dialogs use
-  // the global drupal-modal wrapper by default.
-  $build['dialog_wrappers'] = array('#markup' => '<div id="ajax-test-dialog-wrapper-1"></div><div id="ajax-test-dialog-wrapper-2"></div>');
-
-  // Dialog behavior applied to a button.
-  $build['form'] = drupal_get_form('ajax_test_dialog_form');
-
-  // Dialog behavior applied to a #type => 'link'.
-  $build['link'] = array(
-    '#type' => 'link',
-    '#title' => 'Link 1 (modal)',
-    '#href' => 'ajax-test/dialog-contents',
-    '#attributes' => array(
-      'class' => array('use-ajax'),
-      'data-accepts' => 'application/vnd.drupal-modal',
-    ),
-  );
-
-  // Dialog behavior applied to links rendered by theme_links().
-  $build['links'] = array(
-    '#theme' => 'links',
-    '#links' => array(
-      'link2' => array(
-        'title' => 'Link 2 (modal)',
-        'href' => 'ajax-test/dialog-contents',
-        'attributes' => array(
-          'class' => array('use-ajax'),
-          'data-accepts' => 'application/vnd.drupal-modal',
-          'data-dialog-options' => json_encode(array(
-            'width' => 400,
-          ))
-        ),
-      ),
-      'link3' => array(
-        'title' => 'Link 3 (non-modal)',
-        'href' => 'ajax-test/dialog-contents',
-        'attributes' => array(
-          'class' => array('use-ajax'),
-          'data-accepts' => 'application/vnd.drupal-dialog',
-          'data-dialog-options' => json_encode(array(
-            'target' => 'ajax-test-dialog-wrapper-1',
-            'width' => 800,
-          ))
-        ),
-      ),
-      'link4' => array(
-        'title' => 'Link 4 (close non-modal if open)',
-        'href' => 'ajax-test/dialog-close',
-        'attributes' => array(
-          'class' => array('use-ajax'),
-        ),
-      ),
-      'link5' => array(
-        'title' => 'Link 5 (form)',
-        'href' => 'ajax-test/dialog-form',
-        'attributes' => array(
-          'class' => array('use-ajax'),
-          'data-accepts' => 'application/vnd.drupal-modal',
-        ),
-      ),
-      'link6' => array(
-        'title' => 'Link 6 (entity form)',
-        'href' => 'admin/structure/contact/add',
-        'attributes' => array(
-          'class' => array('use-ajax'),
-          'data-accepts' => 'application/vnd.drupal-modal',
-          'data-dialog-options' => json_encode(array(
-            'width' => 800,
-            'height' => 500,
-          ))
-        ),
-      ),
-      'link7' => array(
-        'title' => 'Link 7 (non-modal, no target)',
-        'href' => 'ajax-test/dialog-contents',
-        'attributes' => array(
-          'class' => array('use-ajax'),
-          'data-accepts' => 'application/vnd.drupal-dialog',
-          'data-dialog-options' => json_encode(array(
-            'width' => 800,
-          ))
-        ),
-      ),
-    ),
-  );
-  return $build;
-}
-
-/**
- * Form builder: Renders buttons with #ajax['dialog'].
- */
-function ajax_test_dialog_form($form, &$form_state) {
-  // In order to use WebTestBase::drupalPostAjaxForm() to POST from a link, we need
-  // to have a dummy field we can set in WebTestBase::drupalPostForm() else it won't
-  // submit anything.
-  $form['textfield'] = array(
-    '#type' => 'hidden'
-  );
-  $form['button1'] = array(
-    '#type' => 'submit',
-    '#name' => 'button1',
-    '#value' => 'Button 1 (modal)',
-    '#ajax' => array(
-      'callback' => 'ajax_test_dialog_form_callback_modal',
-    ),
-  );
-  $form['button2'] = array(
-    '#type' => 'submit',
-    '#name' => 'button2',
-    '#value' => 'Button 2 (non-modal)',
-    '#ajax' => array(
-      'callback' => 'ajax_test_dialog_form_callback_nonmodal',
-    ),
-  );
-  return $form;
-}
-
-/**
- * Non-AJAX behavior of the dialog buttons.
- */
-function ajax_test_dialog_form_submit($form, &$form_state) {
-  $form_state['redirect'] = 'ajax-test/dialog-contents';
-}
-
-/**
- * AJAX callback handler for ajax_test_dialog_form().
- */
-function ajax_test_dialog_form_callback_modal($form, &$form_state) {
-  return _ajax_test_dialog(TRUE);
-}
-
-/**
- * AJAX callback handler for ajax_test_dialog_form().
- */
-function ajax_test_dialog_form_callback_nonmodal($form, &$form_state) {
-  return _ajax_test_dialog(FALSE);
-}
-
-/**
- * Util to render dialog in ajax callback.
- *
- * @param bool $is_modal
- *   (optional) TRUE if modal, FALSE if plain dialog. Defaults to FALSE.
- */
-function _ajax_test_dialog($is_modal = FALSE) {
-  $content = ajax_test_dialog_contents();
-  $response = new AjaxResponse();
-  $title = t('AJAX Dialog contents');
-  $html = drupal_render($content);
-  if ($is_modal) {
-    $response->addCommand(new OpenModalDialogCommand($title, $html));
-  }
-  else {
-    $selector = '#ajax-test-dialog-wrapper-1';
-    $response->addCommand(new OpenDialogCommand($selector, $title, $html));
-  }
-  return $response;
-}
-
-/**
  * Returns example content for dialog tests.
  */
 function ajax_test_dialog_contents() {
diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml b/core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml
index 9453bef..c2abf64 100644
--- a/core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml
+++ b/core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml
@@ -2,13 +2,14 @@ ajax_test.dialog_contents:
   path: '/ajax-test/dialog-contents'
   defaults:
     _content: '\Drupal\ajax_test\Controller\AjaxTestController::dialogContents'
+    _title: 'AJAX Dialog contents'
   requirements:
     _access: 'TRUE'
 
 ajax_test.dialog_form:
   path: '/ajax-test/dialog-form'
   defaults:
-    _form: '\Drupal\ajax_test\AjaxTestForm'
+    _form: '\Drupal\ajax_test\Form\AjaxTestForm'
   requirements:
     _access: 'TRUE'
 
diff --git a/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Controller/AjaxTestController.php b/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Controller/AjaxTestController.php
index d0387ef..defeaf3 100644
--- a/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Controller/AjaxTestController.php
+++ b/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Controller/AjaxTestController.php
@@ -43,10 +43,96 @@ public function renderError() {
   }
 
   /**
-   * @todo Remove ajax_test_dialog().
+   * Renders a form elements and links with #ajax['dialog'].
    */
   public function dialog() {
-    return ajax_test_dialog();
+    // Add two wrapper elements for testing non-modal dialogs. Modal dialogs use
+    // the global drupal-modal wrapper by default.
+    $build['dialog_wrappers'] = array('#markup' => '<div id="ajax-test-dialog-wrapper-1"></div><div id="ajax-test-dialog-wrapper-2"></div>');
+
+    // Dialog behavior applied to a button.
+    $build['form'] = drupal_get_form('Drupal\ajax_test\Form\AjaxTestDialogForm');
+
+    // Dialog behavior applied to a #type => 'link'.
+    $build['link'] = array(
+      '#type' => 'link',
+      '#title' => 'Link 1 (modal)',
+      '#href' => 'ajax-test/dialog-contents',
+      '#attributes' => array(
+        'class' => array('use-ajax'),
+        'data-accepts' => 'application/vnd.drupal-modal',
+      ),
+    );
+
+    // Dialog behavior applied to links rendered by theme_links().
+    $build['links'] = array(
+      '#theme' => 'links',
+      '#links' => array(
+        'link2' => array(
+          'title' => 'Link 2 (modal)',
+          'href' => 'ajax-test/dialog-contents',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+            'data-accepts' => 'application/vnd.drupal-modal',
+            'data-dialog-options' => json_encode(array(
+              'width' => 400,
+            ))
+          ),
+        ),
+        'link3' => array(
+          'title' => 'Link 3 (non-modal)',
+          'href' => 'ajax-test/dialog-contents',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+            'data-accepts' => 'application/vnd.drupal-dialog',
+            'data-dialog-options' => json_encode(array(
+              'target' => 'ajax-test-dialog-wrapper-1',
+              'width' => 800,
+            ))
+          ),
+        ),
+        'link4' => array(
+          'title' => 'Link 4 (close non-modal if open)',
+          'href' => 'ajax-test/dialog-close',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+          ),
+        ),
+        'link5' => array(
+          'title' => 'Link 5 (form)',
+          'href' => 'ajax-test/dialog-form',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+            'data-accepts' => 'application/vnd.drupal-modal',
+          ),
+        ),
+        'link6' => array(
+          'title' => 'Link 6 (entity form)',
+          'href' => 'admin/structure/contact/add',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+            'data-accepts' => 'application/vnd.drupal-modal',
+            'data-dialog-options' => json_encode(array(
+              'width' => 800,
+              'height' => 500,
+            ))
+          ),
+        ),
+        'link7' => array(
+          'title' => 'Link 7 (non-modal, no target)',
+          'href' => 'ajax-test/dialog-contents',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+            'data-accepts' => 'application/vnd.drupal-dialog',
+            'data-dialog-options' => json_encode(array(
+              'width' => 800,
+            ))
+          ),
+        ),
+      ),
+    );
+
+    return $build;
   }
 
   /**
diff --git a/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Form/AjaxTestDialogForm.php b/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Form/AjaxTestDialogForm.php
new file mode 100644
index 0000000..7f7d0da
--- /dev/null
+++ b/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Form/AjaxTestDialogForm.php
@@ -0,0 +1,113 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\ajax_test\Form\AjaxTestDialogForm.
+ */
+
+namespace Drupal\ajax_test\Form;
+
+use Drupal\Core\Form\FormInterface;
+use Drupal\Core\Form\FormBase;
+use Drupal\Component\Utility\String;
+use Drupal\Core\Ajax\AjaxResponse;
+use Drupal\Core\Ajax\OpenModalDialogCommand;
+use Drupal\Core\Ajax\OpenDialogCommand;
+
+/**
+ * Dummy form for testing DialogController with _form routes.
+ */
+class AjaxTestDialogForm extends FormBase implements FormInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    return 'ajax_test_dialog_form';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, array &$form_state) {
+    // In order to use WebTestBase::drupalPostAjaxForm() to POST from a link, we need
+    // to have a dummy field we can set in WebTestBase::drupalPostForm() else it won't
+    // submit anything.
+    $form['textfield'] = array(
+      '#type' => 'hidden'
+    );
+    $form['button1'] = array(
+      '#type' => 'submit',
+      '#name' => 'button1',
+      '#value' => 'Button 1 (modal)',
+      '#ajax' => array(
+        'callback' => array($this, 'modal'),
+      ),
+    );
+    $form['button2'] = array(
+      '#type' => 'submit',
+      '#name' => 'button2',
+      '#value' => 'Button 2 (non-modal)',
+      '#ajax' => array(
+        'callback' => array($this, 'nonModal'),
+      ),
+    );
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validateForm(array &$form, array &$form_state) {
+
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, array &$form_state) {
+    $form_state['redirect'] = 'ajax-test/dialog-contents';
+  }
+
+
+  /**
+   * AJAX callback handler for AjaxTestDialogForm.
+   */
+  public function modal(&$form, &$form_state) {
+    return $this->dialog(TRUE);
+  }
+
+  /**
+   * AJAX callback handler for AjaxTestDialogForm.
+   */
+  public function nonModal(&$form, &$form_state) {
+    return $this->dialog(FALSE);
+  }
+
+
+  /**
+   * Util to render dialog in ajax callback.
+   *
+   * @param bool $is_modal
+   *   (optional) TRUE if modal, FALSE if plain dialog. Defaults to FALSE.
+   *
+   * @return AjaxResponse
+   *   An ajax response object.
+   */
+  protected function dialog($is_modal = FALSE) {
+    $content = ajax_test_dialog_contents();
+    $response = new AjaxResponse();
+    $title = $this->t(String::checkPlain('AJAX Dialog contents'));
+    $html = drupal_render($content);
+    if ($is_modal) {
+      $response->addCommand(new OpenModalDialogCommand($title, $html));
+    }
+    else {
+      $selector = '#ajax-test-dialog-wrapper-1';
+      $response->addCommand(new OpenDialogCommand($selector, $title, $html));
+    }
+    return $response;
+  }
+
+}
diff --git a/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/AjaxTestForm.php b/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Form/AjaxTestForm.php
similarity index 91%
rename from core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/AjaxTestForm.php
rename to core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Form/AjaxTestForm.php
index b3e3613..de5e430 100644
--- a/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/AjaxTestForm.php
+++ b/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Form/AjaxTestForm.php
@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Contains \Drupal\ajax_test\AjaxTestForm.
+ * Contains \Drupal\ajax_test\Form\AjaxTestForm.
  */
 
-namespace Drupal\ajax_test;
+namespace Drupal\ajax_test\Form;
 
 use Drupal\Core\Form\FormInterface;
 
