Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cse493x-24sp/cse493x-24sp-tests
  • wongyh/cse493x-24sp-tests
2 results
Show changes
Commits on Source (20)
...@@ -10,7 +10,7 @@ In the Github repository we create for you, run: ...@@ -10,7 +10,7 @@ In the Github repository we create for you, run:
git submodule update --init git submodule update --init
This command downloads this repository in the `test` subdirectory. This command downloads this repository in the `tests` subdirectory.
Throughout the class, we'll likely push new versions of this Throughout the class, we'll likely push new versions of this
repository, to fix bugs or maybe update class-relevant files. You can repository, to fix bugs or maybe update class-relevant files. You can
...@@ -42,7 +42,7 @@ The same exact script is run by the autograder in Github Actions. ...@@ -42,7 +42,7 @@ The same exact script is run by the autograder in Github Actions.
The tests The tests
--------- ---------
You can find the tests themselves in `src/`. The You can find the tests themselves in the `tests/` subdirectory. (Yes, this is `tests/tests/`) The
`chapterN-base-tests.md` file always contains tests for the base `chapterN-base-tests.md` file always contains tests for the base
browser from the book for Chapter N. You should get those passing browser from the book for Chapter N. You should get those passing
first. The `chapterN-exercise-X-tests.md` file contains the tests for first. The `chapterN-exercise-X-tests.md` file contains the tests for
......
...@@ -21,7 +21,7 @@ CHAPTER_DEADLINES = { ...@@ -21,7 +21,7 @@ CHAPTER_DEADLINES = {
"chapter2": datetime.datetime(2024, 4, 8, tzinfo=PDT), "chapter2": datetime.datetime(2024, 4, 8, tzinfo=PDT),
"chapter3": datetime.datetime(2024, 4, 15, tzinfo=PDT), "chapter3": datetime.datetime(2024, 4, 15, tzinfo=PDT),
"chapter4": datetime.datetime(2024, 4, 22, tzinfo=PDT), "chapter4": datetime.datetime(2024, 4, 22, tzinfo=PDT),
"chapter5": datetime.datetime(2024, 4, 20, tzinfo=PDT), "chapter5": datetime.datetime(2024, 4, 29, tzinfo=PDT),
"chapter6": datetime.datetime(2024, 5, 6, tzinfo=PDT), "chapter6": datetime.datetime(2024, 5, 6, tzinfo=PDT),
"chapter7": datetime.datetime(2024, 5, 13, tzinfo=PDT), "chapter7": datetime.datetime(2024, 5, 13, tzinfo=PDT),
"chapter8": datetime.datetime(2024, 5, 20, tzinfo=PDT), "chapter8": datetime.datetime(2024, 5, 20, tzinfo=PDT),
...@@ -93,6 +93,7 @@ CURRENT_TESTS = { ...@@ -93,6 +93,7 @@ CURRENT_TESTS = {
"chapter8-exercise-check-boxes-tests.md", "chapter8-exercise-check-boxes-tests.md",
"chapter8-exercise-get-forms-tests.md", "chapter8-exercise-get-forms-tests.md",
"chapter8-exercise-rich-buttons-tests.md", "chapter8-exercise-rich-buttons-tests.md",
"chapter8-exercise-tab-tests.md",
], ],
"chapter9": ["chapter9-base-tests.md", "chapter9": ["chapter9-base-tests.md",
"chapter9-exercise-create-element-tests.md", "chapter9-exercise-create-element-tests.md",
......
...@@ -133,7 +133,7 @@ The responses cached earlier should still be valid. ...@@ -133,7 +133,7 @@ The responses cached earlier should still be valid.
Objective: Verify that your caching mechanism doesn't serve stale data when the scheme, host, or port of the requested URL changes. Objective: Verify that your caching mechanism doesn't serve stale data when the scheme, host, or port of the requested URL changes.
>>> URL_base = "http://wbemocks.test/cache_me1" >>> URL_base = "http://wbemocks.test/cache_me4"
>>> wbemocks.socket.respond(url=URL_base, >>> wbemocks.socket.respond(url=URL_base,
... response=("HTTP/1.0 200 Ok\r\n" + ... response=("HTTP/1.0 200 Ok\r\n" +
... "Cache-Control: max-age=9001\r\n" + ... "Cache-Control: max-age=9001\r\n" +
...@@ -142,7 +142,7 @@ The responses cached earlier should still be valid. ...@@ -142,7 +142,7 @@ The responses cached earlier should still be valid.
>>> browser.URL(URL_base).request() >>> browser.URL(URL_base).request()
'Different port page' 'Different port page'
>>> URL_diff_scheme = "https://wbemocks.test/cache_me1" >>> URL_diff_scheme = "https://wbemocks.test/cache_me4"
>>> wbemocks.socket.respond(url=URL_diff_scheme, >>> wbemocks.socket.respond(url=URL_diff_scheme,
... response=("HTTP/1.0 200 Ok\r\n" + ... response=("HTTP/1.0 200 Ok\r\n" +
... "Cache-Control: max-age=9001\r\n" + ... "Cache-Control: max-age=9001\r\n" +
...@@ -151,7 +151,7 @@ The responses cached earlier should still be valid. ...@@ -151,7 +151,7 @@ The responses cached earlier should still be valid.
>>> browser.URL(URL_diff_scheme).request() >>> browser.URL(URL_diff_scheme).request()
'Different scheme page' 'Different scheme page'
>>> URL_diff_host = "http://mock.test/cache_me1" >>> URL_diff_host = "http://mock.test/cache_me4"
>>> wbemocks.socket.respond(url=URL_diff_host, >>> wbemocks.socket.respond(url=URL_diff_host,
... response=("HTTP/1.0 200 Ok\r\n" + ... response=("HTTP/1.0 200 Ok\r\n" +
... "Cache-Control: max-age=9001\r\n" + ... "Cache-Control: max-age=9001\r\n" +
...@@ -161,7 +161,7 @@ The responses cached earlier should still be valid. ...@@ -161,7 +161,7 @@ The responses cached earlier should still be valid.
'Different host page' 'Different host page'
>>> URL_diff_port = "http://wbemocks.test:8080/cache_me1" >>> URL_diff_port = "http://wbemocks.test:8080/cache_me4"
>>> wbemocks.socket.respond(url=URL_diff_port, >>> wbemocks.socket.respond(url=URL_diff_port,
... response=("HTTP/1.0 200 Ok\r\n" + ... response=("HTTP/1.0 200 Ok\r\n" +
... "Cache-Control: max-age=9001\r\n" + ... "Cache-Control: max-age=9001\r\n" +
......
...@@ -68,7 +68,7 @@ Let's see what it looks like: ...@@ -68,7 +68,7 @@ Let's see what it looks like:
>>> b.load(url) >>> b.load(url)
create_text: x=1 y=1 text=H create_text: x=1 y=1 text=H
create_text: x=2 y=1 text=i create_text: x=2 y=1 text=i
create_oval: x=2 y=2 image=PhotoImage('openmoji/1F600.png') create_image: x=2 y=2 image=PhotoImage('openmoji/1F600.png')
create_text: x=2 y=3 text=a create_text: x=2 y=3 text=a
create_text: x=1 y=4 text=n create_text: x=1 y=4 text=n
create_text: x=2 y=4 text=d create_text: x=2 y=4 text=d
......
...@@ -21,6 +21,27 @@ Make sure you have the expected default values for `HSTEP`, `VSTEP`, ...@@ -21,6 +21,27 @@ Make sure you have the expected default values for `HSTEP`, `VSTEP`,
>>> browser.HEIGHT >>> browser.HEIGHT
600 600
Notes
=====
You might need to modify the `__repr__` method on `Text` and `Tag`
if you factored your project into multiple files: (This is especially
true if you see a mismatched output of the form `<layout.Tag object at ...>`)
```
class Text:
...
def __repr__(self):
return "Text('{}')".format(self.text)
class Tag:
...
def __repr__(self):
return "Tag('{}')".format(self.tag)
```
Testing `lex` Testing `lex`
------------- -------------
......
...@@ -81,7 +81,7 @@ You should be able to mix centered and normal text on different lines ...@@ -81,7 +81,7 @@ You should be able to mix centered and normal text on different lines
Ensure that the application correctly handles the transition from centered to regular text within the same sequence Ensure that the application correctly handles the transition from centered to regular text within the same sequence
>>> test_layout('<h1 class="title">center this</h1>then this is regular') >>> test_layout('<h1 class="title">center this</h1>then this is regular') #doctest: +NORMALIZE_WHITESPACE
[(312.0, 21.0, 'center', Font size=16 weight=normal slant=roman style=None), [(312.0, 21.0, 'center', Font size=16 weight=normal slant=roman style=None),
(424.0, 21.0, 'this', Font size=16 weight=normal slant=roman style=None), (424.0, 21.0, 'this', Font size=16 weight=normal slant=roman style=None),
(13.0, 41.0, 'then', Font size=16 weight=normal slant=roman style=None), (13.0, 41.0, 'then', Font size=16 weight=normal slant=roman style=None),
......
...@@ -16,8 +16,7 @@ Testing boilerplate: ...@@ -16,8 +16,7 @@ Testing boilerplate:
>>> _ = wbemocks.ssl.patch().start() >>> _ = wbemocks.ssl.patch().start()
>>> _ = wbemocks.patch_canvas() >>> _ = wbemocks.patch_canvas()
>>> import browser >>> import browser
>>> browser.WIDTH >>> browser.set_parameters(WIDTH=800)
800
>>> def test_layout(text): >>> def test_layout(text):
... dl = browser.Layout(browser.lex(text)).display_list ... dl = browser.Layout(browser.lex(text)).display_list
... return wbemocks.normalize_display_list(dl) ... return wbemocks.normalize_display_list(dl)
......
...@@ -43,7 +43,7 @@ If the word fits without splitting then no literal hyphens are present. ...@@ -43,7 +43,7 @@ If the word fits without splitting then no literal hyphens are present.
When a soft hyphen is replaced with a literal hyphen you need to check that the When a soft hyphen is replaced with a literal hyphen you need to check that the
text with the hyphen fits on the line. text with the hyphen fits on the line.
>>> browser.WIDTH = 90 >>> browser.set_parameters(WIDTH=90)
>>> test_layout("a\N{soft hyphen}b\N{soft hyphen}c\N{soft hyphen}d\N{soft hyphen}e") #doctest: +NORMALIZE_WHITESPACE >>> test_layout("a\N{soft hyphen}b\N{soft hyphen}c\N{soft hyphen}d\N{soft hyphen}e") #doctest: +NORMALIZE_WHITESPACE
[(13.0, 21.0, 'abc-', Font size=16 weight=normal slant=roman style=None), [(13.0, 21.0, 'abc-', Font size=16 weight=normal slant=roman style=None),
(13.0, 41.0, 'de', Font size=16 weight=normal slant=roman style=None)] (13.0, 41.0, 'de', Font size=16 weight=normal slant=roman style=None)]
...@@ -51,7 +51,7 @@ When a soft hyphen is replaced with a literal hyphen you need to check that the ...@@ -51,7 +51,7 @@ When a soft hyphen is replaced with a literal hyphen you need to check that the
Sometimes a word may be so long that it needs to be split multiple times. Sometimes a word may be so long that it needs to be split multiple times.
>>> browser.WIDTH = 122 >>> browser.set_parameters(WIDTH=122)
>>> test_layout("multi\N{soft hyphen}word\N{soft hyphen}split") #doctest: +NORMALIZE_WHITESPACE >>> test_layout("multi\N{soft hyphen}word\N{soft hyphen}split") #doctest: +NORMALIZE_WHITESPACE
[(13.0, 21.0, 'multi-', Font size=16 weight=normal slant=roman style=None), [(13.0, 21.0, 'multi-', Font size=16 weight=normal slant=roman style=None),
(13.0, 41.0, 'word-', Font size=16 weight=normal slant=roman style=None), (13.0, 41.0, 'word-', Font size=16 weight=normal slant=roman style=None),
......
...@@ -13,7 +13,7 @@ interaction. ...@@ -13,7 +13,7 @@ interaction.
Note that we aren't mocking `dukpy`. It should just run JavaScript normally! Note that we aren't mocking `dukpy`. It should just run JavaScript normally!
Testing basic <script> support Testing basic \<script> support
============================== ==============================
The browser should download JavaScript code mentioned in a `<script>` tag: The browser should download JavaScript code mentioned in a `<script>` tag:
......
...@@ -87,7 +87,7 @@ Replace the id with something that has a different id. ...@@ -87,7 +87,7 @@ Replace the id with something that has a different id.
Traceback (most recent call last): Traceback (most recent call last):
... ...
_dukpy.JSRuntimeError: ReferenceError: identifier 'one' undefined _dukpy.JSRuntimeError: ReferenceError: identifier 'one' undefined
at [anon] (duk_js_var.c:1239) internal ...
at eval (eval:1) preventsyield at eval (eval:1) preventsyield
>>> js.run("replacement;") >>> js.run("replacement;")
{'handle': 2} {'handle': 2}
...@@ -110,19 +110,19 @@ Empty the document of ids. ...@@ -110,19 +110,19 @@ Empty the document of ids.
Traceback (most recent call last): Traceback (most recent call last):
... ...
_dukpy.JSRuntimeError: ReferenceError: identifier 'alice' undefined _dukpy.JSRuntimeError: ReferenceError: identifier 'alice' undefined
at [anon] (duk_js_var.c:1239) internal ...
at eval (eval:1) preventsyield at eval (eval:1) preventsyield
>>> js.run("one;") >>> js.run("one;")
Traceback (most recent call last): Traceback (most recent call last):
... ...
_dukpy.JSRuntimeError: ReferenceError: identifier 'one' undefined _dukpy.JSRuntimeError: ReferenceError: identifier 'one' undefined
at [anon] (duk_js_var.c:1239) internal ...
at eval (eval:1) preventsyield at eval (eval:1) preventsyield
>>> js.run("replacement;") >>> js.run("replacement;")
Traceback (most recent call last): Traceback (most recent call last):
... ...
_dukpy.JSRuntimeError: ReferenceError: identifier 'replacement' undefined _dukpy.JSRuntimeError: ReferenceError: identifier 'replacement' undefined
at [anon] (duk_js_var.c:1239) internal ...
at eval (eval:1) preventsyield at eval (eval:1) preventsyield
>>> browser.print_tree(this_browser.active_tab.document) >>> browser.print_tree(this_browser.active_tab.document)
DocumentLayout() DocumentLayout()
......
...@@ -436,6 +436,8 @@ class MockCanvas: ...@@ -436,6 +436,8 @@ class MockCanvas:
else: else:
cmd = "create_text: x={} y={} text={}".format(x, y, text) cmd = "create_text: x={} y={} text={}".format(x, y, text)
self._draw(cmd) self._draw(cmd)
if font is None:
font = MockFont(size=20)
y2 = y + font.metrics("linespace") y2 = y + font.metrics("linespace")
if self._allow("create_text", y2): print(cmd) if self._allow("create_text", y2): print(cmd)
......