123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- goog.setTestOnly('goog.testing.ui.RendererHarness');
- goog.provide('goog.testing.ui.RendererHarness');
- goog.require('goog.Disposable');
- goog.require('goog.dom.NodeType');
- goog.require('goog.testing.asserts');
- goog.require('goog.testing.dom');
- goog.testing.ui.RendererHarness = function(
- renderer, renderParent, decorateParent) {
- goog.Disposable.call(this);
-
- this.renderer_ = renderer;
-
- this.renderParent_ = renderParent;
-
- this.renderHtml_ = renderParent.innerHTML;
-
- this.decorateParent_ = decorateParent;
-
- this.decorateHtml_ = decorateParent.innerHTML;
- };
- goog.inherits(goog.testing.ui.RendererHarness, goog.Disposable);
- goog.testing.ui.RendererHarness.prototype.decorateControl_;
- goog.testing.ui.RendererHarness.prototype.renderControl_;
- goog.testing.ui.RendererHarness.prototype.verified_ = false;
- goog.testing.ui.RendererHarness.prototype.attachControlAndRender = function(
- control) {
- this.renderControl_ = control;
- control.setRenderer(this.renderer_);
- control.render(this.renderParent_);
- return control.getElement();
- };
- goog.testing.ui.RendererHarness.prototype.attachControlAndDecorate = function(
- control) {
- this.decorateControl_ = control;
- control.setRenderer(this.renderer_);
- var child = this.decorateParent_.firstChild;
- assertEquals(
- 'The decorated node must be an element', goog.dom.NodeType.ELEMENT,
- child.nodeType);
- control.decorate( (child));
- return control.getElement();
- };
- goog.testing.ui.RendererHarness.prototype.assertDomMatches = function() {
- assert(
- 'Both elements were not generated',
- !!(this.renderControl_ && this.decorateControl_));
- goog.testing.dom.assertHtmlMatches(
- this.renderControl_.getElement().innerHTML,
- this.decorateControl_.getElement().innerHTML);
- this.verified_ = true;
- };
- goog.testing.ui.RendererHarness.prototype.disposeInternal = function() {
-
- assert(
- 'Expected assertDomMatches to be called',
- this.verified_ || !this.renderControl_ || !this.decorateControl_);
- if (this.decorateControl_) {
- this.decorateControl_.dispose();
- }
- if (this.renderControl_) {
- this.renderControl_.dispose();
- }
- this.renderParent_.innerHTML = this.renderHtml_;
- this.decorateParent_.innerHTML = this.decorateHtml_;
- goog.testing.ui.RendererHarness.superClass_.disposeInternal.call(this);
- };
|