Chris@14: getTestThemes() as $theme) { Chris@14: $this->enableTheme($theme); Chris@14: $this->drupalGet('/off-canvas-test-links'); Chris@14: Chris@14: $page = $this->getSession()->getPage(); Chris@14: $web_assert = $this->assertSession(); Chris@14: Chris@14: // Make sure off-canvas dialog is on page when first loaded. Chris@14: $web_assert->elementNotExists('css', '#drupal-off-canvas'); Chris@14: Chris@14: // Check opening and closing with two separate links. Chris@14: // Make sure tray updates to new content. Chris@14: // Check the first link again to make sure the empty title class is Chris@14: // removed. Chris@14: foreach (['1', '2', '1'] as $link_index) { Chris@14: // Click the first test like that should open the page. Chris@14: $page->clickLink("Click Me $link_index!"); Chris@14: $this->waitForOffCanvasToOpen(); Chris@14: Chris@14: // Check that the canvas is not on the page. Chris@14: $web_assert->elementExists('css', '#drupal-off-canvas'); Chris@14: // Check that response text is on page. Chris@14: $web_assert->pageTextContains("Thing $link_index says hello"); Chris@14: $off_canvas_tray = $this->getOffCanvasDialog(); Chris@14: Chris@14: // Check that tray is visible. Chris@14: $this->assertEquals(TRUE, $off_canvas_tray->isVisible()); Chris@14: $header_text = $off_canvas_tray->find('css', '.ui-dialog-title')->getText(); Chris@14: Chris@14: $tray_text = $off_canvas_tray->findById('drupal-off-canvas')->getText(); Chris@14: $this->assertEquals("Thing $link_index says hello", $tray_text); Chris@14: Chris@14: if ($link_index == '2') { Chris@14: // Check no title behavior. Chris@14: $web_assert->elementExists('css', '.ui-dialog-empty-title'); Chris@14: $this->assertEquals("\xc2\xa0", $header_text); Chris@14: Chris@14: $style = $page->find('css', '.ui-dialog-off-canvas')->getAttribute('style'); Chris@14: $this->assertTrue(strstr($style, 'width: 555px;') !== FALSE, 'Dialog width respected.'); Chris@14: $page->clickLink("Click Me 1!"); Chris@14: $this->waitForOffCanvasToOpen(); Chris@14: $style = $page->find('css', '.ui-dialog-off-canvas')->getAttribute('style'); Chris@14: $this->assertTrue(strstr($style, 'width: 555px;') === FALSE, 'Dialog width reset to default.'); Chris@14: } Chris@14: else { Chris@14: // Check that header is correct. Chris@14: $this->assertEquals("Thing $link_index", $header_text); Chris@14: $web_assert->elementNotExists('css', '.ui-dialog-empty-title'); Chris@14: } Chris@14: } Chris@14: } Chris@14: } Chris@14: Chris@14: /** Chris@14: * Tests the body displacement behaves differently at a narrow width. Chris@14: */ Chris@14: public function testNarrowWidth() { Chris@14: $narrow_width_breakpoint = 768; Chris@14: $offset = 20; Chris@14: $height = 800; Chris@14: $page = $this->getSession()->getPage(); Chris@14: $web_assert = $this->assertSession(); Chris@14: Chris@14: // Test the same functionality on multiple themes. Chris@14: foreach ($this->getTestThemes() as $theme) { Chris@14: $this->enableTheme($theme); Chris@14: // Testing at the wider width. Chris@14: $this->getSession()->resizeWindow($narrow_width_breakpoint + $offset, $height); Chris@14: $this->drupalGet('/off-canvas-test-links'); Chris@14: $this->assertFalse($page->find('css', '.dialog-off-canvas-main-canvas')->hasAttribute('style'), 'Body not padded on wide page load.'); Chris@14: $page->clickLink("Click Me 1!"); Chris@14: $this->waitForOffCanvasToOpen(); Chris@14: // Check that the main canvas is padded when page is not narrow width and Chris@14: // tray is open. Chris@14: $web_assert->elementAttributeContains('css', '.dialog-off-canvas-main-canvas', 'style', 'padding-right'); Chris@14: Chris@14: // Testing at the narrower width. Chris@14: $this->getSession()->resizeWindow($narrow_width_breakpoint - $offset, $height); Chris@14: $this->drupalGet('/off-canvas-test-links'); Chris@14: $this->assertFalse($page->find('css', '.dialog-off-canvas-main-canvas')->hasAttribute('style'), 'Body not padded on narrow page load.'); Chris@14: $page->clickLink("Click Me 1!"); Chris@14: $this->waitForOffCanvasToOpen(); Chris@14: $this->assertFalse($page->find('css', '.dialog-off-canvas-main-canvas')->hasAttribute('style'), 'Body not padded on narrow page with tray open.'); Chris@14: } Chris@14: } Chris@14: Chris@14: }